-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add Tab completion to Add Project path picker #2552
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -96,6 +96,7 @@ import { | |
| getCommandPaletteMode, | ||
| ITEM_ICON_CLASS, | ||
| RECENT_THREAD_LIMIT, | ||
| resolveBrowseTabCompletion, | ||
| } from "./CommandPalette.logic"; | ||
| import { resolveEnvironmentOptionLabel } from "./BranchToolbar.logic"; | ||
| import { CommandPaletteResults } from "./CommandPaletteResults"; | ||
|
|
@@ -1321,6 +1322,32 @@ function OpenCommandPaletteDialog() { | |
| setBrowseGeneration((generation) => generation + 1); | ||
| } | ||
|
|
||
| function completeBrowsePathFromTab(): boolean { | ||
| if (!isBrowsing || relativePathNeedsActiveProject || isBrowsePending) { | ||
| return false; | ||
|
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. Pending Tab still blurs inputMedium Severity
Additional Locations (1)Reviewed by Cursor Bugbot for commit 31ad61b. Configure here. |
||
| } | ||
|
|
||
| const completion = resolveBrowseTabCompletion({ | ||
| filteredEntries: filteredBrowseEntries, | ||
| browseFilterQuery, | ||
| highlightedEntry: highlightedBrowseEntry, | ||
| exactEntry: exactBrowseEntry, | ||
| }); | ||
| if (!completion) { | ||
| return false; | ||
| } | ||
|
|
||
| setHighlightedItemValue(null); | ||
| if (completion._tag === "enterDirectory") { | ||
| setQuery(appendBrowsePathSegment(query, completion.name)); | ||
| setBrowseGeneration((generation) => generation + 1); | ||
| return true; | ||
| } | ||
|
|
||
| setQuery(`${getBrowseDirectoryPath(query)}${completion.leaf}`); | ||
| return true; | ||
| } | ||
|
|
||
| // Resolve the add-project path from browse data when available. When the | ||
| // query has a trailing separator (e.g. "~/projects/foo/"), parentPath is the | ||
| // directory itself. Otherwise the user typed a partial leaf name, so we need | ||
|
|
@@ -1440,6 +1467,11 @@ function OpenCommandPaletteDialog() { | |
| } | ||
|
|
||
| function handleKeyDown(event: KeyboardEvent<HTMLInputElement>): void { | ||
| if (event.key === "Tab" && completeBrowsePathFromTab()) { | ||
| event.preventDefault(); | ||
| return; | ||
|
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. Shift Tab triggers completionLow Severity
Reviewed by Cursor Bugbot for commit 31ad61b. Configure here. |
||
| } | ||
|
|
||
| if (addProjectCloneFlow?.step === "repository" && event.key === "Enter") { | ||
| event.preventDefault(); | ||
| void submitAddProjectCloneFlow(); | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ambiguous Tab picks first directory
Medium Severity
resolveBrowseTabCompletionenters the first filtered directory when multiple matches have no longer common prefix and nothing is highlighted. In browse mode no item is auto-highlighted, so an ambiguousTabcan replace the user's path with an arbitrary directory instead of leaving it unchanged.Reviewed by Cursor Bugbot for commit 31ad61b. Configure here.