Skip to content

Commit 321ffe3

Browse files
committed
Move notified document check
1 parent 890919e commit 321ffe3

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/lsptoolshost/miscellaneousFileNotifier.ts

+12-11
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,33 @@ export function registerMiscellaneousFileNotifier(
1717
context: vscode.ExtensionContext,
1818
languageServer: RoslynLanguageServer
1919
) {
20-
context.workspaceState.update(SuppressMiscellaneousFilesToastsOption, undefined);
21-
2220
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.
2822
if (!e.context._vs_is_miscellaneous || languageServer.state !== ServerState.ProjectInitializationComplete) {
2923
return;
3024
}
3125

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+
) {
3331
return;
3432
}
3533

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)) {
3737
return;
38+
} else {
39+
NotifiedDocuments.add(hash);
3840
}
3941

40-
NotifiedDocuments.add(hash);
41-
4242
const message = vscode.l10n.t(
4343
'The active document is not part of the open workspace. Not all language features will be available.'
4444
);
4545
const dismissItem = vscode.l10n.t('Dismiss');
46+
// Provide the user a way to easily disable the toast without changing settings.
4647
const disableWorkspace: ActionOption = {
4748
title: vscode.l10n.t('Do not show for this workspace'),
4849
action: async () => {

0 commit comments

Comments
 (0)