mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
ServerWorld
This commit is contained in:
parent
41570f60bf
commit
ed7ae78c6f
9 changed files with 246 additions and 182 deletions
|
@ -60,14 +60,18 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
vscode.workspace.onDidChangeTextDocument((event: vscode.TextDocumentChangeEvent) => {
|
||||
let doc = event.document
|
||||
if (doc.languageId != "rust") return
|
||||
// We need to order this after LS updates, but there's no API for that.
|
||||
// Hence, good old setTimeout.
|
||||
setTimeout(() => {
|
||||
afterLs(() => {
|
||||
textDocumentContentProvider.eventEmitter.fire(uris.syntaxTree)
|
||||
}, 10)
|
||||
})
|
||||
}, null, context.subscriptions)
|
||||
}
|
||||
|
||||
// We need to order this after LS updates, but there's no API for that.
|
||||
// Hence, good old setTimeout.
|
||||
function afterLs(f) {
|
||||
setTimeout(f, 10)
|
||||
}
|
||||
|
||||
export function deactivate(): Thenable<void> {
|
||||
if (!client) {
|
||||
return undefined;
|
||||
|
@ -118,7 +122,9 @@ function startServer() {
|
|||
if (editor == null) return
|
||||
if (!editor.selection.isEmpty) return
|
||||
let position = client.protocol2CodeConverter.asPosition(params)
|
||||
editor.selection = new vscode.Selection(position, position);
|
||||
afterLs(() => {
|
||||
editor.selection = new vscode.Selection(position, position)
|
||||
})
|
||||
}
|
||||
)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue