aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/main.ts
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-30 19:21:25 +0000
committerAleksey Kladov <[email protected]>2019-12-30 19:24:30 +0000
commit9ead314005afd835ca64b5db9117e1c495814e17 (patch)
tree67ef26be75ec5db5fd66761a67b65a09e42d363e /editors/code/src/main.ts
parentb8368f09b4857a225ff9e59dd8977ed21c408536 (diff)
Encapsulate inlay hints activation
Diffstat (limited to 'editors/code/src/main.ts')
-rw-r--r--editors/code/src/main.ts39
1 files changed, 2 insertions, 37 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index d6c210579..7e63a9cac 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -2,7 +2,7 @@ import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient'; 2import * as lc from 'vscode-languageclient';
3 3
4import * as commands from './commands'; 4import * as commands from './commands';
5import { HintsUpdater } from './inlay_hints'; 5import { activateInlayHints } from './inlay_hints';
6import { StatusDisplay } from './status_display'; 6import { StatusDisplay } from './status_display';
7import * as events from './events'; 7import * as events from './events';
8import * as notifications from './notifications'; 8import * as notifications from './notifications';
@@ -37,10 +37,6 @@ export async function activate(context: vscode.ExtensionContext) {
37 ); 37 );
38 ctx.pushCleanup(watchStatus); 38 ctx.pushCleanup(watchStatus);
39 39
40 function disposeOnDeactivation(disposable: vscode.Disposable) {
41 context.subscriptions.push(disposable);
42 }
43
44 // Notifications are events triggered by the language server 40 // Notifications are events triggered by the language server
45 const allNotifications: [string, lc.GenericNotificationHandler][] = [ 41 const allNotifications: [string, lc.GenericNotificationHandler][] = [
46 [ 42 [
@@ -71,38 +67,7 @@ export async function activate(context: vscode.ExtensionContext) {
71 } 67 }
72 68
73 if (Server.config.displayInlayHints) { 69 if (Server.config.displayInlayHints) {
74 const hintsUpdater = new HintsUpdater(); 70 activateInlayHints(ctx);
75 hintsUpdater.refreshHintsForVisibleEditors().then(() => {
76 // vscode may ignore top level hintsUpdater.refreshHintsForVisibleEditors()
77 // so update the hints once when the focus changes to guarantee their presence
78 let editorChangeDisposable: vscode.Disposable | null = null;
79 editorChangeDisposable = vscode.window.onDidChangeActiveTextEditor(
80 _ => {
81 if (editorChangeDisposable !== null) {
82 editorChangeDisposable.dispose();
83 }
84 return hintsUpdater.refreshHintsForVisibleEditors();
85 },
86 );
87
88 disposeOnDeactivation(
89 vscode.window.onDidChangeVisibleTextEditors(_ =>
90 hintsUpdater.refreshHintsForVisibleEditors(),
91 ),
92 );
93 disposeOnDeactivation(
94 vscode.workspace.onDidChangeTextDocument(e =>
95 hintsUpdater.refreshHintsForVisibleEditors(e),
96 ),
97 );
98 disposeOnDeactivation(
99 vscode.workspace.onDidChangeConfiguration(_ =>
100 hintsUpdater.toggleHintsDisplay(
101 Server.config.displayInlayHints,
102 ),
103 ),
104 );
105 });
106 } 71 }
107} 72}
108 73