diff options
author | Aleksey Kladov <[email protected]> | 2019-12-30 18:05:41 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-12-30 18:07:59 +0000 |
commit | ca5c59507f76b8e30658d6c815b823c9636d786a (patch) | |
tree | c953cf7eaaf7f6892e7cff63b5b96ff3060826a8 /editors/code/src/events | |
parent | ac3d0e83403be22ec31d62a1501d726f6e6f81e1 (diff) |
Refactor show syntax tree action
Diffstat (limited to 'editors/code/src/events')
-rw-r--r-- | editors/code/src/events/change_active_text_editor.ts | 9 | ||||
-rw-r--r-- | editors/code/src/events/change_text_document.ts | 24 | ||||
-rw-r--r-- | editors/code/src/events/index.ts | 3 |
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 @@ | |||
1 | import { TextEditor } from 'vscode'; | 1 | import { TextEditor } from 'vscode'; |
2 | import { TextDocumentIdentifier } from 'vscode-languageclient'; | 2 | import { TextDocumentIdentifier } from 'vscode-languageclient'; |
3 | |||
4 | import { | ||
5 | SyntaxTreeContentProvider, | ||
6 | syntaxTreeUri, | ||
7 | } from '../commands/syntaxTree'; | ||
8 | import { Decoration } from '../highlighting'; | 3 | import { Decoration } from '../highlighting'; |
9 | import { Server } from '../server'; | 4 | import { Server } from '../server'; |
10 | 5 | ||
11 | export function makeHandler(syntaxTreeProvider: SyntaxTreeContentProvider) { | 6 | export 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 @@ | |||
1 | import * as vscode from 'vscode'; | ||
2 | |||
3 | import { | ||
4 | SyntaxTreeContentProvider, | ||
5 | syntaxTreeUri, | ||
6 | } from '../commands/syntaxTree'; | ||
7 | |||
8 | export 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. | ||
22 | function 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 @@ | |||
1 | import * as changeActiveTextEditor from './change_active_text_editor'; | 1 | import * as changeActiveTextEditor from './change_active_text_editor'; |
2 | import * as changeTextDocument from './change_text_document'; | ||
3 | 2 | ||
4 | export { changeActiveTextEditor, changeTextDocument }; | 3 | export { changeActiveTextEditor }; |