aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/events
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/events')
-rw-r--r--editors/code/src/events/change_active_text_editor.ts9
-rw-r--r--editors/code/src/events/change_text_document.ts24
-rw-r--r--editors/code/src/events/index.ts3
3 files changed, 2 insertions, 34 deletions
diff --git a/editors/code/src/events/change_active_text_editor.ts b/editors/code/src/events/change_active_text_editor.ts
index 74b91bd48..4384ee567 100644
--- a/editors/code/src/events/change_active_text_editor.ts
+++ b/editors/code/src/events/change_active_text_editor.ts
@@ -1,21 +1,14 @@
1import { TextEditor } from 'vscode'; 1import { TextEditor } from 'vscode';
2import { TextDocumentIdentifier } from 'vscode-languageclient'; 2import { TextDocumentIdentifier } from 'vscode-languageclient';
3
4import {
5 SyntaxTreeContentProvider,
6 syntaxTreeUri,
7} from '../commands/syntaxTree';
8import { Decoration } from '../highlighting'; 3import { Decoration } from '../highlighting';
9import { Server } from '../server'; 4import { Server } from '../server';
10 5
11export function makeHandler(syntaxTreeProvider: SyntaxTreeContentProvider) { 6export function makeHandler() {
12 return async function handle(editor: TextEditor | undefined) { 7 return async function handle(editor: TextEditor | undefined) {
13 if (!editor || editor.document.languageId !== 'rust') { 8 if (!editor || editor.document.languageId !== 'rust') {
14 return; 9 return;
15 } 10 }
16 11
17 syntaxTreeProvider.eventEmitter.fire(syntaxTreeUri);
18
19 if (!Server.config.highlightingOn) { 12 if (!Server.config.highlightingOn) {
20 return; 13 return;
21 } 14 }
diff --git a/editors/code/src/events/change_text_document.ts b/editors/code/src/events/change_text_document.ts
deleted file mode 100644
index 2e998e889..000000000
--- a/editors/code/src/events/change_text_document.ts
+++ /dev/null
@@ -1,24 +0,0 @@
1import * as vscode from 'vscode';
2
3import {
4 SyntaxTreeContentProvider,
5 syntaxTreeUri,
6} from '../commands/syntaxTree';
7
8export function createHandler(syntaxTreeProvider: SyntaxTreeContentProvider) {
9 return (event: vscode.TextDocumentChangeEvent) => {
10 const doc = event.document;
11 if (doc.languageId !== 'rust') {
12 return;
13 }
14 afterLs(() => {
15 syntaxTreeProvider.eventEmitter.fire(syntaxTreeUri);
16 });
17 };
18}
19
20// We need to order this after LS updates, but there's no API for that.
21// Hence, good old setTimeout.
22function afterLs(f: () => any) {
23 setTimeout(f, 10);
24}
diff --git a/editors/code/src/events/index.ts b/editors/code/src/events/index.ts
index 4c154563f..be135474d 100644
--- a/editors/code/src/events/index.ts
+++ b/editors/code/src/events/index.ts
@@ -1,4 +1,3 @@
1import * as changeActiveTextEditor from './change_active_text_editor'; 1import * as changeActiveTextEditor from './change_active_text_editor';
2import * as changeTextDocument from './change_text_document';
3 2
4export { changeActiveTextEditor, changeTextDocument }; 3export { changeActiveTextEditor };