From ca5c59507f76b8e30658d6c815b823c9636d786a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 30 Dec 2019 19:05:41 +0100 Subject: Refactor show syntax tree action --- .../code/src/events/change_active_text_editor.ts | 9 +------- editors/code/src/events/change_text_document.ts | 24 ---------------------- editors/code/src/events/index.ts | 3 +-- 3 files changed, 2 insertions(+), 34 deletions(-) delete mode 100644 editors/code/src/events/change_text_document.ts (limited to 'editors/code/src/events') 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 @@ import { TextEditor } from 'vscode'; import { TextDocumentIdentifier } from 'vscode-languageclient'; - -import { - SyntaxTreeContentProvider, - syntaxTreeUri, -} from '../commands/syntaxTree'; import { Decoration } from '../highlighting'; import { Server } from '../server'; -export function makeHandler(syntaxTreeProvider: SyntaxTreeContentProvider) { +export function makeHandler() { return async function handle(editor: TextEditor | undefined) { if (!editor || editor.document.languageId !== 'rust') { return; } - syntaxTreeProvider.eventEmitter.fire(syntaxTreeUri); - if (!Server.config.highlightingOn) { return; } 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 @@ -import * as vscode from 'vscode'; - -import { - SyntaxTreeContentProvider, - syntaxTreeUri, -} from '../commands/syntaxTree'; - -export function createHandler(syntaxTreeProvider: SyntaxTreeContentProvider) { - return (event: vscode.TextDocumentChangeEvent) => { - const doc = event.document; - if (doc.languageId !== 'rust') { - return; - } - afterLs(() => { - syntaxTreeProvider.eventEmitter.fire(syntaxTreeUri); - }); - }; -} - -// We need to order this after LS updates, but there's no API for that. -// Hence, good old setTimeout. -function afterLs(f: () => any) { - setTimeout(f, 10); -} 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 @@ import * as changeActiveTextEditor from './change_active_text_editor'; -import * as changeTextDocument from './change_text_document'; -export { changeActiveTextEditor, changeTextDocument }; +export { changeActiveTextEditor }; -- cgit v1.2.3