Skip to content

Commit

Permalink
fix: Change the suggestions to not include ties by default. (#1678)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S committed Sep 11, 2021
1 parent c7ffcc7 commit 0efbd58
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 30 deletions.
Expand Up @@ -30,6 +30,7 @@ export interface SuggestOptions {
/**
* If multiple suggestions have the same edit / change "cost", then included them even if
* it causes more than `numSuggestions` to be returned.
* @default false
*/
includeTies?: boolean;
/**
Expand Down
23 changes: 0 additions & 23 deletions packages/cspell-lib/src/__snapshots__/validator.test.ts.snap
Expand Up @@ -17,7 +17,6 @@ Array [
"witch",
"with",
"Witt",
"width",
],
"text": "witth",
},
Expand All @@ -36,27 +35,6 @@ Array [
"few's",
"fe's",
"feal",
"fear",
"feat",
"feck",
"feds",
"feed",
"feel",
"feer",
"fees",
"feet",
"fell",
"felt",
"feme",
"fend",
"fens",
"fern",
"fess",
"fest",
"feta",
"fete",
"feud",
"flews",
],
"text": "feww",
},
Expand All @@ -75,7 +53,6 @@ Array [
"mistaken",
"mistaker",
"mistake's",
"mistakers",
],
"text": "mistaks",
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-lib/src/validator.ts
Expand Up @@ -35,7 +35,7 @@ export async function validateText(
.suggest(t.text, {
numSuggestions: options.numSuggestions,
compoundMethod: CompoundWordsMethod.NONE,
includeTies: true,
includeTies: false,
ignoreCase: !(settings.caseSensitive ?? false),
timeout: settings.suggestionsTimeout,
numChanges: settings.suggestionNumChanges,
Expand Down
6 changes: 3 additions & 3 deletions packages/cspell-trie-lib/src/lib/genSuggestionsOptions.ts
Expand Up @@ -31,7 +31,7 @@ export interface SuggestionOptionsStrict extends GenSuggestionOptionsStrict {
* Allow ties when making suggestions.
* if `true` it is possible to have more than `numSuggestions`.
*/
allowTies: boolean;
includeTies: boolean;

/**
* Time alloted in milliseconds to generate suggestions.
Expand All @@ -56,7 +56,7 @@ export const defaultGenSuggestionOptions: GenSuggestionOptionsStrict = {
export const defaultSuggestionOptions: SuggestionOptionsStrict = {
...defaultGenSuggestionOptions,
numSuggestions: 8,
allowTies: true,
includeTies: true,
timeout: 5000,
};

Expand All @@ -76,7 +76,7 @@ const keyMapOfGenSuggestionOptionsStrict: KeyMapOfGenSuggestionOptionsStrict = {

const keyMapOfSuggestionOptionsStrict: KeyMapOfSuggestionOptionsStrict = {
...keyMapOfGenSuggestionOptionsStrict,
allowTies: 'allowTies',
includeTies: 'includeTies',
filter: 'filter',
numSuggestions: 'numSuggestions',
timeout: 'timeout',
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-trie-lib/src/lib/suggest.ts
Expand Up @@ -23,7 +23,7 @@ export function suggest(
const collector = suggestionCollector(word, {
numSuggestions: opts.numSuggestions,
changeLimit: opts.changeLimit,
includeTies: opts.allowTies,
includeTies: opts.includeTies,
ignoreCase: opts.ignoreCase,
timeout: opts.timeout,
filter: opts.filter,
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-trie-lib/src/lib/suggestAStar.ts
Expand Up @@ -476,7 +476,7 @@ export function suggest(root: TrieRoot | TrieRoot[], word: string, options: Sugg
const collector = suggestionCollector(word, {
numSuggestions: opts.numSuggestions,
changeLimit: opts.changeLimit,
includeTies: true,
includeTies: opts.includeTies,
ignoreCase: opts.ignoreCase,
timeout: opts.timeout,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/cspell-trie-lib/src/lib/suggestCollector.ts
Expand Up @@ -129,7 +129,7 @@ export const defaultSuggestionCollectorOptions: SuggestionCollectorOptions = {
numSuggestions: defaultMaxNumberSuggestions,
filter: () => true,
changeLimit: MAX_NUM_CHANGES,
includeTies: true,
includeTies: false,
ignoreCase: true,
timeout: DEFAULT_COLLECTOR_TIMEOUT,
};
Expand Down

0 comments on commit 0efbd58

Please sign in to comment.