@@ -17,32 +17,33 @@ export function registerMiscellaneousFileNotifier(
17
17
context : vscode . ExtensionContext ,
18
18
languageServer : RoslynLanguageServer
19
19
) {
20
- context . workspaceState . update ( SuppressMiscellaneousFilesToastsOption , undefined ) ;
21
-
22
20
languageServer . _projectContextService . onActiveFileContextChanged ( ( e ) => {
23
- const hash = createHash ( e . uri . toString ( /*skipEncoding:*/ true ) ) ;
24
- if ( NotifiedDocuments . has ( hash ) ) {
25
- return ;
26
- }
27
-
21
+ // Only warn for miscellaneous files when the workspace is fully initialized.
28
22
if ( ! e . context . _vs_is_miscellaneous || languageServer . state !== ServerState . ProjectInitializationComplete ) {
29
23
return ;
30
24
}
31
25
32
- if ( languageServerOptions . suppressMiscellaneousFilesToasts ) {
26
+ // Check settings and workspaceState to see if we should suppress the toast.
27
+ if (
28
+ languageServerOptions . suppressMiscellaneousFilesToasts ||
29
+ context . workspaceState . get < boolean > ( SuppressMiscellaneousFilesToastsOption , false )
30
+ ) {
33
31
return ;
34
32
}
35
33
36
- if ( context . workspaceState . get < boolean > ( SuppressMiscellaneousFilesToastsOption , false ) ) {
34
+ // Check to see if we have already notified the user about this document.
35
+ const hash = createHash ( e . uri . toString ( /*skipEncoding:*/ true ) ) ;
36
+ if ( NotifiedDocuments . has ( hash ) ) {
37
37
return ;
38
+ } else {
39
+ NotifiedDocuments . add ( hash ) ;
38
40
}
39
41
40
- NotifiedDocuments . add ( hash ) ;
41
-
42
42
const message = vscode . l10n . t (
43
43
'The active document is not part of the open workspace. Not all language features will be available.'
44
44
) ;
45
45
const dismissItem = vscode . l10n . t ( 'Dismiss' ) ;
46
+ // Provide the user a way to easily disable the toast without changing settings.
46
47
const disableWorkspace : ActionOption = {
47
48
title : vscode . l10n . t ( 'Do not show for this workspace' ) ,
48
49
action : async ( ) => {
0 commit comments