-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
[search-in-workspace] Add history to input fields #9524
Conversation
packages/search-in-workspace/src/browser/components/input-with-history.tsx
Outdated
Show resolved
Hide resolved
In VSCode, the history is also stored across sessions, so it would be nice to add the history to the state of SIW widget, and restore it on restart: theia/packages/search-in-workspace/src/browser/search-in-workspace-widget.tsx Lines 164 to 176 in 8eb33e3
|
Hm, github is really unhappy with the rebase. |
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.
I noticed a bug when restoring the input history after reload:
- perform multiple searches (ex: 3-4)
- delete the content in the input (so it is empty)
- reload the application
- attempt to cycle through the input history (arrow up or arrow down)
- the history is unavailable
It looks like history is only available if the app is reloaded when there is content in the input field.
Thanks for catching that. It's now fixed. |
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.
Thanks for catching that. It's now fixed.
There's still something slightly funny going on here. I did the following:
- Enter some values
- Navigate in the history a bit
- Come back to the end of the history
- Clear the input.
- Refresh
After the refersh, the state was restored, but when I pressed ↑ it took me to the penultimate item in my history, and ↓ then took me to the last item in the history. It seems that it kept track of the history, but believed that the index was targeting the last non-empty item, even though that wasn't what was displayed. Maybe the empty string should be added to the history for the purposes of index tracking, but ignored if the user is trying to navigate the history?
packages/search-in-workspace/src/browser/components/input-with-history.tsx
Outdated
Show resolved
Hide resolved
@@ -188,6 +198,18 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge | |||
this.showReplaceField = oldState.showReplaceField; | |||
this.resultTreeWidget.replaceTerm = this.replaceTerm; | |||
this.resultTreeWidget.showReplaceButtons = this.showReplaceField; | |||
if (this.searchRef.current) { |
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.
These could all be this.someRef.current?.setState(...)
This is actually correct behavior! VS Code does the same. In both, what's happening is that the index of your location in the history is persisted until changed by ↑ or ↓ or adding a new non-empty value . The behavior is easiest to observe if you follow these steps:
|
I'm not sure that the latter fact implies the former, in this case 😉. At least, 'Show me the item before the item I'm not seeing,' isn't what I thought ↑ meant. |
That's quite reasonable. After some discussion outside GitHub, we have two proposed differences in behavior from VS Code:
IMO, they're easier to understand and more convenient. |
We'll merge this one next week, if there are no objections. |
e0a05da
to
bbcb98e
Compare
(Squashed & rebased onto the tip of |
packages/search-in-workspace/src/browser/components/input-with-history.tsx
Outdated
Show resolved
Hide resolved
Signed-off-by: Gabriel Bodeen <[email protected]>
Signed-off-by: Gabriel Bodeen [email protected]
What it does
Fixes #8959.
Some debatable choices:
Mostly these choices were driven by KISS.
How to test
Review checklist
Reminder for reviewers