Transition OnEnter to WorkspaceSnippetEdit
This also changes our handiling of snippet edits on the client side. `editor.insertSnippet` unfortunately forces indentation, which we really don't want to have to deal with. So, let's just implement our manual hacky way of dealing with a simple subset of snippets we actually use in rust-analyzer
This commit is contained in:
@@ -102,7 +102,7 @@ pub enum OnEnter {}
|
||||
|
||||
impl Request for OnEnter {
|
||||
type Params = lsp_types::TextDocumentPositionParams;
|
||||
type Result = Option<SourceChange>;
|
||||
type Result = Option<SnippetWorkspaceEdit>;
|
||||
const METHOD: &'static str = "rust-analyzer/onEnter";
|
||||
}
|
||||
|
||||
|
||||
@@ -159,12 +159,12 @@ pub fn handle_join_lines(
|
||||
pub fn handle_on_enter(
|
||||
world: WorldSnapshot,
|
||||
params: lsp_types::TextDocumentPositionParams,
|
||||
) -> Result<Option<lsp_ext::SourceChange>> {
|
||||
) -> Result<Option<lsp_ext::SnippetWorkspaceEdit>> {
|
||||
let _p = profile("handle_on_enter");
|
||||
let position = from_proto::file_position(&world, params)?;
|
||||
match world.analysis().on_enter(position)? {
|
||||
None => Ok(None),
|
||||
Some(source_change) => to_proto::source_change(&world, source_change).map(Some),
|
||||
Some(source_change) => to_proto::snippet_workspace_edit(&world, source_change).map(Some),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user