Skip to content

Commit

Permalink
fix: Adjust the default settings (#3089)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Mar 6, 2024
1 parent 65f59fb commit 9d92dda
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 34 deletions.
10 changes: 6 additions & 4 deletions docs/_includes/generated-docs/configuration.md
Expand Up @@ -436,10 +436,12 @@ Scope
: resource

Description
: Issues found by the spell checker are marked with a Diagnostic Severity Level. This affects the color of the squiggle.
: The Diagnostic Severity Level determines how issues are shown in the Problems Pane and within the document.
Set the level to `Hint` to hide the issues from the Problems Pane. Use the `#cSpell.decorateIssues#`
to control how issues are displayed in the document.

Default
: _`"Information"`_
: _`"Hint"`_

---

Expand Down Expand Up @@ -977,7 +979,7 @@ This only applies when there is a CSpell configuration file in the workspace.
Note: this setting is used in conjunction with `#cSpell.mergeCSpellSettingsFields#`.

Default
: _`false`_
: _`true`_

Version
: 4.0.0
Expand Down Expand Up @@ -1499,7 +1501,7 @@ Description
: Draw custom decorations on Spelling Issues when the `#cSpell.diagnosticLevel#` is `Hint`.

Default
: _`false`_
: _`true`_

Version
: 4.0.0
Expand Down
12 changes: 6 additions & 6 deletions package.json
Expand Up @@ -734,7 +734,7 @@
"type": "string"
},
"diagnosticLevel": {
"default": "Information",
"default": "Hint",
"enum": [
"Error",
"Warning",
Expand All @@ -747,7 +747,7 @@
"Report Spelling Issues as Information",
"Report Spelling Issues as Hints, will not show up in Problems"
],
"markdownDescription": "Issues found by the spell checker are marked with a Diagnostic Severity Level. This affects the color of the squiggle.",
"markdownDescription": "The Diagnostic Severity Level determines how issues are shown in the Problems Pane and within the document.\nSet the level to `Hint` to hide the issues from the Problems Pane. Use the `#cSpell.decorateIssues#`\nto control how issues are displayed in the document.",
"scope": "resource",
"title": "Set Diagnostic Reporting Level",
"type": "string"
Expand Down Expand Up @@ -1651,7 +1651,7 @@
"type": "array"
},
"cSpell.mergeCSpellSettings": {
"default": false,
"default": true,
"markdownDescription": "Specify if fields from `.vscode/settings.json` are passed to the spell checker.\nThis only applies when there is a CSpell configuration file in the workspace.\n\nThe purpose of this setting to help provide a consistent result compared to the\nCSpell spell checker command line tool.\n\nValues:\n- `true` - all settings will be merged based upon `#cSpell.mergeCSpellSettingsFields#`.\n- `false` - only use `.vscode/settings.json` if a CSpell configuration is not found.\n\nNote: this setting is used in conjunction with `#cSpell.mergeCSpellSettingsFields#`.",
"scope": "resource",
"type": "boolean",
Expand Down Expand Up @@ -2545,7 +2545,7 @@
"type": "object"
},
"cSpell.decorateIssues": {
"default": false,
"default": true,
"markdownDescription": "Draw custom decorations on Spelling Issues when the `#cSpell.diagnosticLevel#` is `Hint`.",
"scope": "application",
"type": "boolean",
Expand Down Expand Up @@ -3256,7 +3256,7 @@
"type": "boolean"
},
"cSpell.diagnosticLevel": {
"default": "Information",
"default": "Hint",
"enum": [
"Error",
"Warning",
Expand All @@ -3269,7 +3269,7 @@
"Report Spelling Issues as Information",
"Report Spelling Issues as Hints, will not show up in Problems"
],
"markdownDescription": "Issues found by the spell checker are marked with a Diagnostic Severity Level. This affects the color of the squiggle.",
"markdownDescription": "The Diagnostic Severity Level determines how issues are shown in the Problems Pane and within the document.\nSet the level to `Hint` to hide the issues from the Problems Pane. Use the `#cSpell.decorateIssues#`\nto control how issues are displayed in the document.",
"scope": "resource",
"title": "Set Diagnostic Reporting Level",
"type": "string"
Expand Down
36 changes: 24 additions & 12 deletions packages/_integrationTests/src/extension.test.mts
Expand Up @@ -11,7 +11,17 @@ import { stream } from 'kefir';
import type { Diagnostic, languages as vscodeLanguages, Position, Uri, window as vscodeWindow } from 'vscode';

import type { CSpellClient, ExtensionApi, OnSpellCheckDocumentStep } from './ExtensionApi.mjs';
import { activateExtension, getDocUri, loadDocument, log, logYellow, sampleWorkspaceUri, sleep } from './helper.mjs';
import {
activateExtension,
getDocUri,
getVscodeWorkspace,
loadDocument,
loadFolder,
log,
logYellow,
sampleWorkspaceUri,
sleep,
} from './helper.mjs';

type VscodeLanguages = typeof vscodeLanguages;
type VscodeWindow = typeof vscodeWindow;
Expand Down Expand Up @@ -61,7 +71,7 @@ describe('Launch code spell extension', function () {
});

it('Verify the extension starts', async () => {
await logYellow('Verify the extension starts');
logYellow('Verify the extension starts');
const extContext = await activateExtension();
const docContext = await loadDocument(docUri);
expect(extContext).to.not.be.undefined;
Expand All @@ -71,15 +81,15 @@ describe('Launch code spell extension', function () {
expect(extApi).to.equal(extContext?.extActivate);
expect(extApi).haveOwnProperty(apiSignature.addWordToUserDictionary);
expect(extApi).to.include.all.keys(...Object.keys(apiSignature));
await logYellow('Done: Verify the extension starts');
logYellow('Done: Verify the extension starts');
});

[
[getDocUri('example.md'), getDocUri('cspell.json')],
[sampleWorkspaceUri('workspace1/README.md'), sampleWorkspaceUri('cspell.json')],
].forEach(([docUri, expectedConfigUri]) => {
it(`Verifies that the right config was found for ${docUri.toString()}`, async () => {
await logYellow('Verifies that the right config was found');
logYellow('Verifies that the right config was found');
const ext = isDefined(await activateExtension());
const uri = docUri;
const docContextMaybe = await loadDocument(uri);
Expand All @@ -89,17 +99,19 @@ describe('Launch code spell extension', function () {
const config = await ext.extApi.cSpellClient().getConfigurationForDocument(docContext.doc);

const { excludedBy, fileEnabled, configFiles } = config;
await log('config: %o', { excludedBy, fileEnabled, configFiles });
log('config: %o', { excludedBy, fileEnabled, configFiles });

const configUri = vscode.Uri.parse(config.configFiles[0] || '');
expect(configUri.toString()).to.equal(expectedConfigUri.toString());
await logYellow('Done: Verifies that the right config was found');
logYellow('Done: Verifies that the right config was found');
});
});

it('Verifies that some spelling errors were found', async () => {
await logYellow('Verifies that some spelling errors were found');
logYellow('Verifies that some spelling errors were found');
await loadFolder(getDocUri('.'));
const uri = getDocUri('example.md');
await getVscodeWorkspace().getConfiguration(undefined, uri).update('cSpell.diagnosticLevel', 'Information');
const docContextMaybe = await loadDocument(uri);
await sleep(500);
// Force a spell check by making an edit.
Expand All @@ -109,25 +121,25 @@ describe('Launch code spell extension', function () {
await r;

const found = await wait;
await log('found %o', found);
log('found %o', found);

const diags = await getDiagsFromVsCode(uri, 2000);

if (!diags.length) {
await log('all diags: %o', vscode.languages.getDiagnostics());
log('all diags: %o', vscode.languages.getDiagnostics());
}

// await sleep(5 * 1000);

expect(found).to.not.be.undefined;

const msgs = diags.map((a) => `C: ${a.source} M: ${a.message}`).join('\n');
await log(`Diag Messages: size(${diags.length}) msg: \n${msgs}`);
await log('diags: %o', diags);
log(`Diag Messages: size(${diags.length}) msg: \n${msgs}`);
log('diags: %o', diags);

// cspell:ignore spellling
expect(msgs).contains('spellling');
await logYellow('Done: Verifies that some spelling errors were found');
logYellow('Done: Verifies that some spelling errors were found');
});

it('Wait a bit', async () => {
Expand Down
8 changes: 8 additions & 0 deletions packages/_integrationTests/src/helper.mts
Expand Up @@ -70,6 +70,14 @@ export async function loadDocument(docUri: Uri): Promise<DocumentContext | undef
}
}

export async function loadFolder(folderUri: Uri): Promise<void> {
return await vscode.commands.executeCommand('vscode.openFolder', folderUri);
}

export function getVscodeWorkspace(): typeof vscode.workspace {
return vscode.workspace;
}

export async function sleep(ms: number): Promise<undefined> {
return new Promise((resolve) => setTimeout(() => resolve(undefined), ms));
}
Expand Down
3 changes: 3 additions & 0 deletions packages/_integrationTests/testFixtures/.vscode/settings.json
@@ -0,0 +1,3 @@
{
"cSpell.diagnosticLevel": "Information"
}
16 changes: 8 additions & 8 deletions packages/_server/spell-checker-config.schema.json
Expand Up @@ -133,8 +133,8 @@
"type": "string"
},
"diagnosticLevel": {
"default": "Information",
"description": "Issues found by the spell checker are marked with a Diagnostic Severity Level. This affects the color of the squiggle.",
"default": "Hint",
"description": "The Diagnostic Severity Level determines how issues are shown in the Problems Pane and within the document. Set the level to `Hint` to hide the issues from the Problems Pane. Use the `#cSpell.decorateIssues#` to control how issues are displayed in the document.",
"enum": [
"Error",
"Warning",
Expand All @@ -147,7 +147,7 @@
"Report Spelling Issues as Information",
"Report Spelling Issues as Hints, will not show up in Problems"
],
"markdownDescription": "Issues found by the spell checker are marked with a Diagnostic Severity Level. This affects the color of the squiggle.",
"markdownDescription": "The Diagnostic Severity Level determines how issues are shown in the Problems Pane and within the document.\nSet the level to `Hint` to hide the issues from the Problems Pane. Use the `#cSpell.decorateIssues#`\nto control how issues are displayed in the document.",
"scope": "resource",
"title": "Set Diagnostic Reporting Level",
"type": "string"
Expand Down Expand Up @@ -1182,7 +1182,7 @@
"type": "array"
},
"cSpell.mergeCSpellSettings": {
"default": false,
"default": true,
"description": "Specify if fields from `.vscode/settings.json` are passed to the spell checker. This only applies when there is a CSpell configuration file in the workspace.\n\nThe purpose of this setting to help provide a consistent result compared to the CSpell spell checker command line tool.\n\nValues:\n- `true` - all settings will be merged based upon `#cSpell.mergeCSpellSettingsFields#`.\n- `false` - only use `.vscode/settings.json` if a CSpell configuration is not found.\n\nNote: this setting is used in conjunction with `#cSpell.mergeCSpellSettingsFields#`.",
"markdownDescription": "Specify if fields from `.vscode/settings.json` are passed to the spell checker.\nThis only applies when there is a CSpell configuration file in the workspace.\n\nThe purpose of this setting to help provide a consistent result compared to the\nCSpell spell checker command line tool.\n\nValues:\n- `true` - all settings will be merged based upon `#cSpell.mergeCSpellSettingsFields#`.\n- `false` - only use `.vscode/settings.json` if a CSpell configuration is not found.\n\nNote: this setting is used in conjunction with `#cSpell.mergeCSpellSettingsFields#`.",
"scope": "resource",
Expand Down Expand Up @@ -2184,7 +2184,7 @@
"type": "object"
},
"cSpell.decorateIssues": {
"default": false,
"default": true,
"description": "Draw custom decorations on Spelling Issues when the `#cSpell.diagnosticLevel#` is `Hint`.",
"markdownDescription": "Draw custom decorations on Spelling Issues when the `#cSpell.diagnosticLevel#` is `Hint`.",
"scope": "application",
Expand Down Expand Up @@ -2975,8 +2975,8 @@
"type": "boolean"
},
"cSpell.diagnosticLevel": {
"default": "Information",
"description": "Issues found by the spell checker are marked with a Diagnostic Severity Level. This affects the color of the squiggle.",
"default": "Hint",
"description": "The Diagnostic Severity Level determines how issues are shown in the Problems Pane and within the document. Set the level to `Hint` to hide the issues from the Problems Pane. Use the `#cSpell.decorateIssues#` to control how issues are displayed in the document.",
"enum": [
"Error",
"Warning",
Expand All @@ -2989,7 +2989,7 @@
"Report Spelling Issues as Information",
"Report Spelling Issues as Hints, will not show up in Problems"
],
"markdownDescription": "Issues found by the spell checker are marked with a Diagnostic Severity Level. This affects the color of the squiggle.",
"markdownDescription": "The Diagnostic Severity Level determines how issues are shown in the Problems Pane and within the document.\nSet the level to `Hint` to hide the issues from the Problems Pane. Use the `#cSpell.decorateIssues#`\nto control how issues are displayed in the document.",
"scope": "resource",
"title": "Set Diagnostic Reporting Level",
"type": "string"
Expand Down
Expand Up @@ -178,7 +178,7 @@ export interface AppearanceSettings extends Appearance {
*
* @scope application
* @version 4.0.0
* @default false
* @default true
*/
decorateIssues?: boolean;
}
Expand Up @@ -27,10 +27,12 @@ export interface SpellCheckerSettings extends SpellCheckerShouldCheckDocSettings
checkLimit?: number;

/**
* Issues found by the spell checker are marked with a Diagnostic Severity Level. This affects the color of the squiggle.
* The Diagnostic Severity Level determines how issues are shown in the Problems Pane and within the document.
* Set the level to `Hint` to hide the issues from the Problems Pane. Use the `#cSpell.decorateIssues#`
* to control how issues are displayed in the document.
* @title Set Diagnostic Reporting Level
* @scope resource
* @default "Information"
* @default "Hint"
* @enumDescriptions [
* "Report Spelling Issues as Errors",
* "Report Spelling Issues as Warnings",
Expand Down Expand Up @@ -375,7 +377,7 @@ export interface SpellCheckerSettings extends SpellCheckerShouldCheckDocSettings
*
* @scope resource
* @version 4.0.0
* @default false
* @default true
*/
mergeCSpellSettings?: boolean;

Expand Down
1 change: 1 addition & 0 deletions packages/client/src/issueViewer/issuesViewerByFile.ts
Expand Up @@ -516,6 +516,7 @@ function collectIssuesByFile(context: Context): FileWithIssuesTreeItem[] {
const comp = new Intl.Collator().compare;

const sorted = [...groupedByFile]
.filter(([_, issues]) => issues.length)
.map(([doc, issues]) => new FileWithIssuesTreeItem(context, doc, issues))
.sort((a, b) => comp(a.document.uri.toString(true), b.document.uri.toString(true)));

Expand Down

0 comments on commit 9d92dda

Please sign in to comment.