File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -1013,6 +1013,17 @@ async function activateWithInstalledDistribution(
1013
1013
void ideServer . stop ( ) ;
1014
1014
} ,
1015
1015
} ) ;
1016
+
1017
+ // Handle visibility changes in the ideserver
1018
+ if ( await cliServer . cliConstraints . supportsVisibilityNotifications ( ) ) {
1019
+ Window . onDidChangeVisibleTextEditors ( ( editors ) => {
1020
+ ideServer . notifyVisibilityChange ( editors ) ;
1021
+ } ) ;
1022
+ // Send an inital notification to the language server
1023
+ // to set the initial state of the visible editors.
1024
+ ideServer . notifyVisibilityChange ( Window . visibleTextEditors ) ;
1025
+ }
1026
+
1016
1027
// Jump-to-definition and find-references
1017
1028
void extLogger . log ( "Registering jump-to-definition handlers." ) ;
1018
1029
Original file line number Diff line number Diff line change 1
- import { ProgressLocation , window } from "vscode" ;
2
- import { LanguageClient , StreamInfo } from "vscode-languageclient/node" ;
1
+ import { ProgressLocation , TextEditor , window } from "vscode" ;
2
+ import {
3
+ LanguageClient ,
4
+ NotificationType ,
5
+ StreamInfo ,
6
+ } from "vscode-languageclient/node" ;
3
7
import { shouldDebugIdeServer , spawnServer } from "../codeql-cli/cli" ;
4
8
import { QueryServerConfig } from "../config" ;
5
9
import { ideServerLogger } from "../common" ;
@@ -41,6 +45,15 @@ export class CodeQLLanguageClient extends LanguageClient {
41
45
true ,
42
46
) ;
43
47
}
48
+
49
+ notifyVisibilityChange ( editors : readonly TextEditor [ ] ) {
50
+ const files = editors
51
+ . filter ( ( e ) => e . document . uri . scheme === "file" )
52
+ . map ( ( e ) => e . document . uri . toString ( ) ) ;
53
+ void this . sendNotification ( didChangeVisibileFiles , {
54
+ visibleFiles : files ,
55
+ } ) ;
56
+ }
44
57
}
45
58
46
59
/** Starts a new CodeQL language server process, sending progress messages to the status bar. */
@@ -70,3 +83,13 @@ async function spawnIdeServer(config: QueryServerConfig): Promise<StreamInfo> {
70
83
} ,
71
84
) ;
72
85
}
86
+
87
+ /**
88
+ * Custom notification type for when the set of visible files changes.
89
+ */
90
+ interface DidChangeVisibileFilesParams {
91
+ visibleFiles : string [ ] ;
92
+ }
93
+
94
+ const didChangeVisibileFiles : NotificationType < DidChangeVisibileFilesParams > =
95
+ new NotificationType ( "textDocument/codeQLDidChangeVisibleFiles" ) ;
You can’t perform that action at this time.
0 commit comments