Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Display suggestions -- regression #976

Merged
merged 1 commit into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions packages/cspell-lib/src/spellCheckFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {
mergeSettings,
searchForConfig,
} from './Settings';
import { validateText, ValidationIssue } from './validator';
import { validateText, ValidateTextOptions, ValidationIssue } from './validator';
import * as path from 'path';
import { combineTextAndLanguageSettings } from './Settings/TextDocumentSettings';

export interface SpellCheckFileOptions {
export interface SpellCheckFileOptions extends ValidateTextOptions {
/**
* Optional path to a configuration file.
* If given, it will be used instead of searching for a configuration file.
Expand Down Expand Up @@ -148,8 +148,10 @@ async function spellCheckFullDocument(
const docSettings = determineFinalDocumentSettings(document, config);

const shouldCheck = docSettings.settings.enabled ?? true;
const { generateSuggestions, numSuggestions } = options;
const validateOptions = { generateSuggestions, numSuggestions };

const issues = shouldCheck ? await validateText(document.text, docSettings.settings) : [];
const issues = shouldCheck ? await validateText(document.text, docSettings.settings, validateOptions) : [];

const result: SpellCheckFileResult = {
document,
Expand Down
2 changes: 2 additions & 0 deletions packages/cspell-lib/src/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export interface ValidationIssue extends Text.TextOffset {
}

export interface ValidateTextOptions {
/** Generate suggestions where there are spelling issues. */
generateSuggestions?: boolean;
/** The number of suggestions to generate. The higher the number the longer it takes. */
numSuggestions?: number;
}

Expand Down
3 changes: 2 additions & 1 deletion packages/cspell/src/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export function runLint(cfg: CSpellApplicationConfiguration): Promise<RunResult>
MessageTypes.Info
);
try {
const r = await cspell.spellCheckDocument(doc, {}, configInfo.config);
const validateOptions = { generateSuggestions: cfg.options.showSuggestions, numSuggestions: 5 };
const r = await cspell.spellCheckDocument(doc, validateOptions, configInfo.config);
spellResult = r;
result.processed = r.checked;
result.issues = cspell.Text.calculateTextDocumentOffsets(filename, text, r.issues).map(mapIssue);
Expand Down