Skip to content

Commit

Permalink
fix: Display suggestions -- regression (#976)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S authored Feb 19, 2021
1 parent ca1b7c2 commit e3970c7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
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

0 comments on commit e3970c7

Please sign in to comment.