diff options
Diffstat (limited to 'code/src')
-rw-r--r-- | code/src/extension.ts | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/code/src/extension.ts b/code/src/extension.ts index 95305db2d..084a9d769 100644 --- a/code/src/extension.ts +++ b/code/src/extension.ts | |||
@@ -60,14 +60,18 @@ export function activate(context: vscode.ExtensionContext) { | |||
60 | vscode.workspace.onDidChangeTextDocument((event: vscode.TextDocumentChangeEvent) => { | 60 | vscode.workspace.onDidChangeTextDocument((event: vscode.TextDocumentChangeEvent) => { |
61 | let doc = event.document | 61 | let doc = event.document |
62 | if (doc.languageId != "rust") return | 62 | if (doc.languageId != "rust") return |
63 | // We need to order this after LS updates, but there's no API for that. | 63 | afterLs(() => { |
64 | // Hence, good old setTimeout. | ||
65 | setTimeout(() => { | ||
66 | textDocumentContentProvider.eventEmitter.fire(uris.syntaxTree) | 64 | textDocumentContentProvider.eventEmitter.fire(uris.syntaxTree) |
67 | }, 10) | 65 | }) |
68 | }, null, context.subscriptions) | 66 | }, null, context.subscriptions) |
69 | } | 67 | } |
70 | 68 | ||
69 | // We need to order this after LS updates, but there's no API for that. | ||
70 | // Hence, good old setTimeout. | ||
71 | function afterLs(f) { | ||
72 | setTimeout(f, 10) | ||
73 | } | ||
74 | |||
71 | export function deactivate(): Thenable<void> { | 75 | export function deactivate(): Thenable<void> { |
72 | if (!client) { | 76 | if (!client) { |
73 | return undefined; | 77 | return undefined; |
@@ -118,7 +122,9 @@ function startServer() { | |||
118 | if (editor == null) return | 122 | if (editor == null) return |
119 | if (!editor.selection.isEmpty) return | 123 | if (!editor.selection.isEmpty) return |
120 | let position = client.protocol2CodeConverter.asPosition(params) | 124 | let position = client.protocol2CodeConverter.asPosition(params) |
121 | editor.selection = new vscode.Selection(position, position); | 125 | afterLs(() => { |
126 | editor.selection = new vscode.Selection(position, position) | ||
127 | }) | ||
122 | } | 128 | } |
123 | ) | 129 | ) |
124 | }) | 130 | }) |