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

Use Number.MAX_SAFE_INTEGER in file quick search #11232

Merged
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
4 changes: 2 additions & 2 deletions examples/api-tests/src/file-search.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ describe('file-search', function () {
});

it('should not place very good matches above exact matches', () => {
const exactMatch = 'aa_bb_cc_dd.file';
const veryGoodMatch = 'aa_bb_cc_ed_fd.file';
const exactMatch = 'almost_absurdly_long_file_name_with_many_parts.file';
const veryGoodMatch = 'almost_absurdly_long_file_name_with_many_parts_plus_one.file';
quickFileOpenService['filterAndRange'] = { filter: exactMatch };
/** @type import ('@theia/file-search/lib/browser/quick-file-open').FileQuickPickItem*/
const a = { label: exactMatch, uri: new Uri.default(exactMatch) };
Expand Down
4 changes: 2 additions & 2 deletions packages/file-search/src/browser/quick-file-open.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { OpenerService, KeybindingRegistry, QuickAccessRegistry, QuickAccessProv
import { WorkspaceService } from '@theia/workspace/lib/browser/workspace-service';
import URI from '@theia/core/lib/common/uri';
import { FileSearchService, WHITESPACE_QUERY_SEPARATOR } from '../common/file-search-service';
import { CancellationToken, Command, nls, MAX_SAFE_INTEGER } from '@theia/core/lib/common';
import { CancellationToken, Command, nls } from '@theia/core/lib/common';
import { LabelProvider } from '@theia/core/lib/browser/label-provider';
import { NavigationLocationService } from '@theia/editor/lib/browser/navigation/navigation-location-service';
import * as fuzzy from '@theia/core/shared/fuzzy';
Expand Down Expand Up @@ -245,7 +245,7 @@ export class QuickFileOpenService implements QuickAccessProvider {
// Check fuzzy matches.
const fuzzyMatch = fuzzy.match(queryJoin, str) ?? { score: 0 };
if (fuzzyMatch.score === Infinity && exactMatch) {
return MAX_SAFE_INTEGER;
return Number.MAX_SAFE_INTEGER;
}

return fuzzyMatch.score + partialMatches + (exactMatch ? QuickFileOpenService.Scores.exact : 0);
Expand Down