Skip to content

Commit

Permalink
Move notified document check
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeRobich committed Oct 10, 2024
1 parent 890919e commit 321ffe3
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/lsptoolshost/miscellaneousFileNotifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,33 @@ export function registerMiscellaneousFileNotifier(
context: vscode.ExtensionContext,
languageServer: RoslynLanguageServer
) {
context.workspaceState.update(SuppressMiscellaneousFilesToastsOption, undefined);

languageServer._projectContextService.onActiveFileContextChanged((e) => {
const hash = createHash(e.uri.toString(/*skipEncoding:*/ true));
if (NotifiedDocuments.has(hash)) {
return;
}

// Only warn for miscellaneous files when the workspace is fully initialized.
if (!e.context._vs_is_miscellaneous || languageServer.state !== ServerState.ProjectInitializationComplete) {
return;
}

if (languageServerOptions.suppressMiscellaneousFilesToasts) {
// Check settings and workspaceState to see if we should suppress the toast.
if (
languageServerOptions.suppressMiscellaneousFilesToasts ||
context.workspaceState.get<boolean>(SuppressMiscellaneousFilesToastsOption, false)
) {
return;
}

if (context.workspaceState.get<boolean>(SuppressMiscellaneousFilesToastsOption, false)) {
// Check to see if we have already notified the user about this document.
const hash = createHash(e.uri.toString(/*skipEncoding:*/ true));
if (NotifiedDocuments.has(hash)) {
return;
} else {
NotifiedDocuments.add(hash);
}

NotifiedDocuments.add(hash);

const message = vscode.l10n.t(
'The active document is not part of the open workspace. Not all language features will be available.'
);
const dismissItem = vscode.l10n.t('Dismiss');
// Provide the user a way to easily disable the toast without changing settings.
const disableWorkspace: ActionOption = {
title: vscode.l10n.t('Do not show for this workspace'),
action: async () => {
Expand Down

0 comments on commit 321ffe3

Please sign in to comment.