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: Change the suggestions to not include ties by default. #1678

Merged
merged 1 commit into from Sep 11, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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