Repository navigation
fix(web): Tab completes folder names in the add-project browser #28243
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
Changes from 2 commits
28122f9
0a9b40b
b40c7e6
a070dce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -85,6 +85,29 @@ export function filterFilesystemBrowseEntries( | |
| return { visibleEntries, exactEntry }; | ||
| } | ||
|
|
||
| /** Shell-style Tab: a single match enters the directory, several extend to their common prefix. */ | ||
| export function getFilesystemBrowseTabCompletion( | ||
| visibleEntries: ReadonlyArray<FilesystemBrowseEntry>, | ||
| filterQuery: string, | ||
| ): { readonly name: string; readonly isComplete: boolean } | null { | ||
| const [first, ...rest] = visibleEntries; | ||
| if (first === undefined) return null; | ||
| if (rest.length === 0) return { name: first.name, isComplete: true }; | ||
| let prefix = Array.from(first.name); | ||
| for (const entry of rest) { | ||
| const characters = Array.from(entry.name); | ||
| let length = 0; | ||
| while ( | ||
| length < prefix.length && | ||
| prefix[length]?.toLowerCase() === characters[length]?.toLowerCase() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep all visible matches after completion. For entries Check that the completed prefix still matches every visible entry under the full-string filter. Add this case to the existing test.
|
||
| ) | ||
| length += 1; | ||
| prefix = prefix.slice(0, length); | ||
| } | ||
| const name = prefix.join(""); | ||
| return name.length > filterQuery.length ? { name, isComplete: false } : null; | ||
| } | ||
|
|
||
| export function createBrowseNavigationCoordinator() { | ||
| let generation = 0; | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.