-
Notifications
You must be signed in to change notification settings - Fork 1
π¨ Palette: Add Clear Search action to empty state #422
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 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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ## 2024-05-18 - Added "Clear Search" Action to Empty State | ||
| **Learning:** When users encounter an empty search state, providing an actionable recovery path directly in the list (like a "Clear Search" command) significantly reduces friction compared to requiring manual deletion. Additionally, programmatically clearing a `QuickPick.value` in VS Code does not trigger `onDidChangeValue`, so the associated search/refresh logic must be called manually to reset the UI state. | ||
| **Action:** Always include an actionable "Clear" or "Reset" option directly within empty state UI elements, and remember to manually trigger update handlers when programmatically modifying VS Code `QuickPick` input values. | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -76,6 +76,7 @@ export class SearchProvider { | |||||||||||||||||||||||||||||||||||||||||||||
| private readonly CMD_REBUILD_INDEX = 'command:rebuild-index'; | ||||||||||||||||||||||||||||||||||||||||||||||
| private readonly CMD_CLEAR_CACHE = 'command:clear-cache'; | ||||||||||||||||||||||||||||||||||||||||||||||
| private readonly CMD_SETTINGS = 'command:open-settings'; | ||||||||||||||||||||||||||||||||||||||||||||||
| private readonly CMD_CLEAR_SEARCH = 'command:clear-search'; | ||||||||||||||||||||||||||||||||||||||||||||||
| private readonly ID_EMPTY_STATE = 'empty-state'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| private static readonly CANCEL_BUTTON: vscode.QuickInputButton = { | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1528,6 +1529,18 @@ export class SearchProvider { | |||||||||||||||||||||||||||||||||||||||||||||
| selected: SearchResultItem, | ||||||||||||||||||||||||||||||||||||||||||||||
| quickPick: vscode.QuickPick<SearchResultItem>, | ||||||||||||||||||||||||||||||||||||||||||||||
| ): Promise<boolean> { | ||||||||||||||||||||||||||||||||||||||||||||||
| if (selected.result.item.id === this.CMD_CLEAR_SEARCH) { | ||||||||||||||||||||||||||||||||||||||||||||||
| quickPick.value = ''; | ||||||||||||||||||||||||||||||||||||||||||||||
| // Manually trigger query change to show history again since onDidChangeValue won't fire programmatically | ||||||||||||||||||||||||||||||||||||||||||||||
| this.handleQueryChange( | ||||||||||||||||||||||||||||||||||||||||||||||
| quickPick, | ||||||||||||||||||||||||||||||||||||||||||||||
| '', | ||||||||||||||||||||||||||||||||||||||||||||||
| () => {}, | ||||||||||||||||||||||||||||||||||||||||||||||
| () => {}, | ||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1532
to
+1542
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.
π Proposed fix- if (selected.result.item.id === this.CMD_CLEAR_SEARCH) {
- quickPick.value = '';
- // Manually trigger query change to show history again since onDidChangeValue won't fire programmatically
- this.handleQueryChange(
- quickPick,
- '',
- () => {},
- () => {},
- );
- return true;
- }
+ if (selected.result.item.id === this.CMD_CLEAR_SEARCH) {
+ quickPick.value = '';
+ // Manually trigger query change to show history again since onDidChangeValue won't fire programmatically
+ await this.handleQueryChange(
+ quickPick,
+ '',
+ () => {},
+ () => {},
+ );
+ return true;
+ }As per coding guidelines: "Prefer π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if (selected.result.item.id === this.CMD_NATIVE_SEARCH) { | ||||||||||||||||||||||||||||||||||||||||||||||
| await vscode.commands.executeCommand('workbench.action.findInFiles', { | ||||||||||||||||||||||||||||||||||||||||||||||
| query: quickPick.value, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1654,7 +1667,17 @@ export class SearchProvider { | |||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // 3. Native Search Action | ||||||||||||||||||||||||||||||||||||||||||||||
| // 3. Clear Search Action (if query is not empty) | ||||||||||||||||||||||||||||||||||||||||||||||
| if (query.trim().length > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||
| addCommandItem( | ||||||||||||||||||||||||||||||||||||||||||||||
| 'Clear Search', | ||||||||||||||||||||||||||||||||||||||||||||||
| 'Clear current query and start over', | ||||||||||||||||||||||||||||||||||||||||||||||
| new vscode.ThemeIcon('clear-all'), | ||||||||||||||||||||||||||||||||||||||||||||||
| this.CMD_CLEAR_SEARCH, | ||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| // 4. Native Search Action | ||||||||||||||||||||||||||||||||||||||||||||||
| addCommandItem( | ||||||||||||||||||||||||||||||||||||||||||||||
| 'Search in Files (Native)', | ||||||||||||||||||||||||||||||||||||||||||||||
| "Use VS Code's native search", | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
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.
Incorrect date β should be 2026, not 2024
The heading reads
2024-05-18but the PR was opened in May 2026. Consider updating to2026-05-08(or the actual merge date) to keep the changelog accurate.π€ Prompt for AI Agents