diff --git a/packages/_server/src/server.mts b/packages/_server/src/server.mts index d932868c15..fcde12327d 100644 --- a/packages/_server/src/server.mts +++ b/packages/_server/src/server.mts @@ -42,6 +42,7 @@ import { isUriBlockedBySettings, stringifyPatterns, } from './config/documentSettings.mjs'; +import { isUrlIncludedByDefault } from './config/docUriHelper.mjs'; import { isFileTypeEnabled } from './config/extractEnabledFileTypes.mjs'; import { sanitizeSettings } from './config/sanitizeSettings.mjs'; import type { TextDocumentUri } from './config/vscode.config.mjs'; @@ -592,6 +593,7 @@ export function run(): void { }; } async function isUriExcluded(uri: string): Promise { + if (isUrlIncludedByDefault(uri)) return false; const ie = await calcFileIncludeExclude(uri); return !ie.include || ie.exclude || !!ie.ignored; } diff --git a/packages/client/src/actionMenu.mts b/packages/client/src/actionMenu.mts index 44afd05c27..efcd9008a1 100644 --- a/packages/client/src/actionMenu.mts +++ b/packages/client/src/actionMenu.mts @@ -5,6 +5,7 @@ import type { Disposable, QuickPickItem } from 'vscode'; import vscode from 'vscode'; import { knownCommands } from './commands.mjs'; +import { extensionId } from './constants.js'; import { getClient } from './di.mjs'; import { updateEnabledFileTypeForResource, updateEnabledSchemesResource } from './settings/settings.mjs'; import { handleErrors } from './util/errors.js'; @@ -57,7 +58,7 @@ async function actionMenu(options: ActionsMenuOptions) { command: 'workbench.action.openGlobalKeybindings', arguments: ['Spell:'], }), - itemCommand({ title: '$(gear) Edit Settings...', command: 'workbench.action.openSettings', arguments: ['cSpell'] }), + itemCommand({ title: '$(gear) Edit Settings...', command: 'workbench.action.openSettings', arguments: [extensionId] }), ].filter(isDefined); return quickPickMenu({ items, title: 'Spell Checker Actions Menu' }).catch(() => undefined); diff --git a/packages/client/src/client/client.mts b/packages/client/src/client/client.mts index 21327bc24a..acec87cb14 100644 --- a/packages/client/src/client/client.mts +++ b/packages/client/src/client/client.mts @@ -110,7 +110,7 @@ export class CSpellClient implements Disposable { }, middleware: { handleDiagnostics(uri, diagnostics, next) { - // console.error(`${new Date().toISOString()} Client handleDiagnostics: ${uri.toString()}`); + logger.log(`${new Date().toISOString()} Client handleDiagnostics: ${uri.toString()}`); next(uri, diagnostics); }, }, diff --git a/packages/client/src/decorators/decorateIssues.mts b/packages/client/src/decorators/decorateIssues.mts index 395c4e6ae2..946f6644e2 100644 --- a/packages/client/src/decorators/decorateIssues.mts +++ b/packages/client/src/decorators/decorateIssues.mts @@ -5,6 +5,7 @@ import vscode, { ColorThemeKind, MarkdownString, Range, window, workspace } from import type { PartialCSpellUserSettings } from '../client/index.mjs'; import { commandUri, createTextEditCommand } from '../commands.mjs'; +import { extensionId } from '../constants.js'; import type { Disposable } from '../disposable.js'; import type { IssueTracker, SpellingCheckerIssue } from '../issueTracker.mjs'; import type { CSpellSettings } from '../settings/index.mjs'; @@ -209,7 +210,7 @@ export class SpellingIssueDecorator implements Disposable { } private getConfiguration() { - const cfg = workspace.getConfiguration('cSpell') as PartialCSpellUserSettings< + const cfg = workspace.getConfiguration(extensionId) as PartialCSpellUserSettings< 'hideIssuesWhileTyping' | 'revealIssuesAfterDelayMS' | 'doNotUseCustomDecorationForScheme' >; this.hideIssuesWhileTyping = cfg.hideIssuesWhileTyping ?? defaultHideIssuesWhileTyping; @@ -237,11 +238,11 @@ export class SpellingIssueDecorator implements Disposable { } | undefined { this.clearDecoration(); - const useCustomDecorations = this.visible && (workspace.getConfiguration('cSpell').get('useCustomDecorations') ?? true); + const useCustomDecorations = this.visible && (workspace.getConfiguration(extensionId).get('useCustomDecorations') ?? true); if (!useCustomDecorations) return undefined; const mode = calcMode(window.activeColorTheme.kind); - const cfg = workspace.getConfiguration('cSpell') as PartialCSpellUserSettings< + const cfg = workspace.getConfiguration(extensionId) as PartialCSpellUserSettings< | 'dark' | 'doNotUseCustomDecorationForScheme' | 'hideIssuesWhileTyping' @@ -362,7 +363,7 @@ export class SpellingIssueDecorator implements Disposable { } #onConfigChange(e: vscode.ConfigurationChangeEvent) { - if (!e.affectsConfiguration('cSpell')) return; + if (!e.affectsConfiguration(extensionId)) return; this.resetDecorator(); } diff --git a/packages/client/src/decorators/traceDecorations.mts b/packages/client/src/decorators/traceDecorations.mts index f30b47af6c..ac021ffab6 100644 --- a/packages/client/src/decorators/traceDecorations.mts +++ b/packages/client/src/decorators/traceDecorations.mts @@ -3,6 +3,7 @@ import type { TextEditorDecorationType } from 'vscode'; import vscode from 'vscode'; import type { CSpellClient } from '../client/index.mjs'; +import { extensionId } from '../constants.js'; import type { Disposable } from '../disposable.js'; import { createEmitter, map, pipe, throttle } from '../Subscribables/index.js'; import { logError } from '../util/errors.js'; @@ -27,7 +28,7 @@ export class SpellingExclusionsDecorator implements Disposable { this.disposables.push( () => this.clearDecoration(), vscode.window.onDidChangeActiveTextEditor((e) => this.refreshEditor(e)), - vscode.workspace.onDidChangeConfiguration((e) => e.affectsConfiguration('cSpell') && this.refreshEditor(undefined)), + vscode.workspace.onDidChangeConfiguration((e) => e.affectsConfiguration(extensionId) && this.refreshEditor(undefined)), vscode.workspace.onDidChangeTextDocument((e) => this.refreshDocument(e.document)), vscode.languages.registerHoverProvider('*', this.getHoverProvider()), pipe( diff --git a/packages/client/src/diags.mts b/packages/client/src/diags.mts index 8fe509fbb7..e02a7a954a 100644 --- a/packages/client/src/diags.mts +++ b/packages/client/src/diags.mts @@ -3,7 +3,7 @@ import { createDisposableList } from 'utils-disposables'; import type { Diagnostic, Disposable, Event, Range, Selection, TabChangeEvent, TextDocument, TextEditor, Uri } from 'vscode'; import vscode from 'vscode'; -import { diagnosticSource } from './constants.js'; +import { diagnosticSource, extensionId } from './constants.js'; import { getDependencies } from './di.mjs'; import type { SpellingDiagnostic } from './issueTracker.mjs'; import type { CSpellSettings } from './settings/CSpellSettings.mjs'; @@ -88,12 +88,12 @@ function determineWordRangeToAddToDictionaryFromSelection( export function registerDiagWatcher(show: boolean, onShowChange: Event): Disposable { const dList = createDisposableList(); const issueTracker = getDependencies().issueTracker; - const collection = vscode.languages.createDiagnosticCollection('cSpell'); + const collection = vscode.languages.createDiagnosticCollection(diagnosticSource); let overrides: CSpellSettings[typeof ConfigFields.doNotUseCustomDecorationForScheme]; let useDiagnosticCollection = true; function updateConfig() { - const cfg = vscode.workspace.getConfiguration('cSpell'); + const cfg = vscode.workspace.getConfiguration(extensionId); useDiagnosticCollection = !cfg.get(ConfigFields.useCustomDecorations); overrides = cfg.get(ConfigFields.doNotUseCustomDecorationForScheme); } diff --git a/packages/client/src/extension.mts b/packages/client/src/extension.mts index 88658ff825..b8a74fb6d8 100644 --- a/packages/client/src/extension.mts +++ b/packages/client/src/extension.mts @@ -81,8 +81,6 @@ async function _activate(context: ExtensionContext, eIssueTracker: vscode.EventE dataFileDirUri: vscode.Uri.joinPath(dataFileUri, '..').toJSON(), workspaceState: context.workspaceState.keys(), globalState: context.globalState.keys(), - // contextKeys: cki.filter((k) => k.key.startsWith('cSpell')), - // commands: commands.filter((c) => c.toLowerCase().includes('command')), }); } diff --git a/packages/client/src/issueViewer/IssueTreeItemBase.ts b/packages/client/src/issueViewer/IssueTreeItemBase.ts index fcf1ef22c6..0d53ebeee5 100644 --- a/packages/client/src/issueViewer/IssueTreeItemBase.ts +++ b/packages/client/src/issueViewer/IssueTreeItemBase.ts @@ -4,4 +4,5 @@ export abstract class IssueTreeItemBase { abstract getTreeItem(): TreeItem | Promise; abstract getChildren(): ProviderResult; abstract getParent(): ProviderResult; + abstract toString(): string; } diff --git a/packages/client/src/issueViewer/issuesViewerByFile.mts b/packages/client/src/issueViewer/issuesViewerByFile.mts index 36c5c45fe9..8a51edba62 100644 --- a/packages/client/src/issueViewer/issuesViewerByFile.mts +++ b/packages/client/src/issueViewer/issuesViewerByFile.mts @@ -359,6 +359,10 @@ class FileWithIssuesTreeItem extends IssueTreeItemBase { this.targets = this.context.issueTracker.getConfigurationTargets(this.document.uri).then((r) => ({ targets: r.configTargets })); return this.targets; }; + + toString(): string { + return `FileWithIssuesTreeItem: ${this.document.uri.toString()}`; + } } class FileIssueTreeItem extends IssueTreeItemBase { @@ -413,6 +417,7 @@ class FileIssueTreeItem extends IssueTreeItemBase { getChildren() { if (this.children) return this.children; this.pChildren ??= this.#getChildren(); + return undefined; } async #getChildren() { @@ -447,6 +452,10 @@ class FileIssueTreeItem extends IssueTreeItemBase { // return md; } + toString(): string { + return `FileIssueTreeItem: ${this.issue.diag.message}`; + } + static compare(a: FileIssueTreeItem, b: FileIssueTreeItem) { const cellComp = a.cellIndex - b.cellIndex; if (cellComp) return cellComp; @@ -499,6 +508,10 @@ class IssueSuggestionTreeItem extends IssueTreeItemBase { isPreferred(): boolean { return this.suggestion.isPreferred || false; } + + toString(): string { + return `IssueSuggestionTreeItem: ${this.issue.word} -> ${this.suggestion.word}`; + } } class IssueAddToTargetTreeItem extends IssueTreeItemBase { @@ -544,6 +557,10 @@ class IssueAddToTargetTreeItem extends IssueTreeItemBase { 'addWordsToConfig', ); } + + toString(): string { + return `IssueAddToTargetTreeItem: ${this.issue.word} to ${this.target.name}`; + } } interface FileIssue { diff --git a/packages/client/src/issueViewer/unknownWordsViewer.mts b/packages/client/src/issueViewer/unknownWordsViewer.mts index e8daebed3a..8fadb82701 100644 --- a/packages/client/src/issueViewer/unknownWordsViewer.mts +++ b/packages/client/src/issueViewer/unknownWordsViewer.mts @@ -313,6 +313,10 @@ class WordIssueTreeItem extends IssueTreeItemBase { this.suggestions = gatherSuggestions(this.suggestionsByDocument); this.context.invalidate(this); } + + toString(): string { + return `WordIssueTreeItem ${this.word}`; + } } class IssueLocationsTreeItem extends IssueTreeItemBase { @@ -338,6 +342,10 @@ class IssueLocationsTreeItem extends IssueTreeItemBase { getParent(): IssueTreeItemBase | undefined { return this.parent; } + + toString(): string { + return `IssueLocationsTreeItem ${this.word}`; + } } class IssueFixesTreeItem extends IssueTreeItemBase { @@ -363,6 +371,10 @@ class IssueFixesTreeItem extends IssueTreeItemBase { getParent(): IssueTreeItemBase | undefined { return this.parent; } + + toString(): string { + return `IssueFixesTreeItem ${this.word}`; + } } class IssueLocationTreeItem extends IssueTreeItemBase { @@ -410,6 +422,10 @@ class IssueLocationTreeItem extends IssueTreeItemBase { return this.issue.range; } + toString(): string { + return `IssueLocationTreeItem ${this.issue.word}`; + } + static compare(a: IssueLocationTreeItem, b: IssueLocationTreeItem) { const uriA = a.cell?.document.uri || a.doc.uri; const uriB = b.cell?.document.uri || b.doc.uri; @@ -478,6 +494,10 @@ class IssueSuggestionTreeItem extends IssueTreeItemBase { isPreferred(): boolean { return this.suggestion.isPreferred || false; } + + toString(): string { + return `IssueSuggestionTreeItem ${this.word}`; + } } function collectIssues(context: Context): WordIssueTreeItem[] { diff --git a/packages/client/src/statusbar/languageStatus.mts b/packages/client/src/statusbar/languageStatus.mts index b05be070b3..3f898289f4 100644 --- a/packages/client/src/statusbar/languageStatus.mts +++ b/packages/client/src/statusbar/languageStatus.mts @@ -5,6 +5,7 @@ import vscode from 'vscode'; import type { ServerResponseIsSpellCheckEnabledForFile } from '../client/client.mjs'; import { knownCommands } from '../commands.mjs'; +import { extensionId } from '../constants.js'; import { getClient, getIssueTracker } from '../di.mjs'; import type { IssuesStats } from '../issueTracker.mjs'; import { handleErrors } from '../util/errors.js'; @@ -28,7 +29,7 @@ export function createLanguageStatus(options: LanguageStatusOptions): Disposable dList.push(vscode.window.onDidChangeActiveTextEditor(queueUpdate)); dList.push( vscode.workspace.onDidChangeConfiguration((e) => { - if (e.affectsConfiguration('cSpell')) queueUpdate(); + if (e.affectsConfiguration(extensionId)) queueUpdate(); }), ); dList.push(getIssueTracker().onDidChangeDiagnostics(() => updateNow())); diff --git a/packages/client/src/storage/context.mts b/packages/client/src/storage/context.mts index 7ca5ed79b9..564df433ff 100644 --- a/packages/client/src/storage/context.mts +++ b/packages/client/src/storage/context.mts @@ -102,7 +102,7 @@ async function _setContext(context: ContextTypes): Promise { * @param prefix - optional prefix to use for the context keys */ export async function setContext(context: ContextTypes, prefix = 'cSpell.context'): Promise { - assert(prefix.startsWith('cSpell')); + assert(prefix.startsWith(extensionId)); const kvpValues = [...flatten(prefix, context)]; const filteredKvpValues = kvpValues.filter(([k, v]) => v !== currentContext.get(k)); diff --git a/packages/client/src/vscode/createIsUriVisibleFilter.mts b/packages/client/src/vscode/createIsUriVisibleFilter.mts index 15460ab4bc..4b0e11cd85 100644 --- a/packages/client/src/vscode/createIsUriVisibleFilter.mts +++ b/packages/client/src/vscode/createIsUriVisibleFilter.mts @@ -2,6 +2,8 @@ import { type Uri, window } from 'vscode'; import { findTabsWithUriInput } from './tabs.mjs'; +const alwaysVisibleSchemes = new Set(['vscode-scm']); + export function createIsUriVisibleFilter(onlyVisible: boolean): (uri: Uri) => boolean { if (!onlyVisible) return () => true; // Use the path to avoid scheme issues. @@ -12,7 +14,7 @@ export function createIsUriVisibleFilter(onlyVisible: boolean): (uri: Uri) => bo ...window.visibleTextEditors.map((e) => e.document.uri.toString()), ]); return (uri: Uri) => { - const h = visibleUris.has(uri.toString()); + const h = visibleUris.has(uri.toString()) || alwaysVisibleSchemes.has(uri.scheme); // console.log('isUriVisible', uri.toString(), h); return h; };