Skip to content

Commit

Permalink
Fix autocomplete for incomplete terms like memento:
Browse files Browse the repository at this point in the history
  • Loading branch information
bhollis committed Nov 13, 2024
1 parent 661c2a5 commit 3c3ae3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/app/search/autocomplete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ describe('autocompleteTermSuggestions', () => {
['is:bow is:v|oid', 'is:bow is:void'],
['season:>outl', 'season:>outlaw'],
['not(', 'Expected failure'],
['memento:', 'memento:any'],
['foo memento:', 'foo memento:any'],
];

const plainStringCases: [query: string, mockCandidate: string][] = [['jotu', 'jötunn']];
Expand Down
4 changes: 2 additions & 2 deletions src/app/search/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { compact, uniqBy } from 'app/utils/collections';
import { chainComparator, compareBy, reverseComparator } from 'app/utils/comparators';
import { ArmoryEntry, getArmorySuggestions } from './armory-search';
import { canonicalFilterFormats } from './filter-types';
import { QueryLexerOpenQuotesError, lexer, makeCommentString, parseQuery } from './query-parser';
import { lexer, makeCommentString, parseQuery, QueryLexerError } from './query-parser';
import { FiltersMap, SearchConfig, Suggestion } from './search-config';
import { plainString } from './text-utils';

Expand Down Expand Up @@ -281,7 +281,7 @@ function findLastFilter(queryUpToCaret: string): number[] | null {
}
} catch (e) {
// If the lexer failed because of unmatched quotes, that's *definitely* something to autocomplete!
if (e instanceof QueryLexerOpenQuotesError) {
if (e instanceof QueryLexerError) {
incompleteFilterIndices = [e.startIndex];
}
}
Expand Down

0 comments on commit 3c3ae3a

Please sign in to comment.