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
Add updateTextFromFindWidgetOrSelection method to SearchView #108401
Conversation
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.
Looks good, but could we share the block of code that does the update? We can have two methods like getTextFrom*
and one place that does the update.
@roblourens Thank you for your review! I have extracted updateText method to share the block of code that does the update. And added code that updates regular expression option when updating text from find widget. About having private getTextFromFindWidget(): string | null {
const activeEditor = this.editorService.activeTextEditorControl;
if (!isCodeEditor(activeEditor)) {
return null;
}
const controller = CommonFindController.get(activeEditor as ICodeEditor);
const searchString = controller.getState().searchString;
return searchString !== '' && controller.isFindInputFocused() ? searchString : null;
} is a bit confusing because this method checks whether the find widget is focused or not although As to if (this.searchWidget.searchInput.getRegex()) {
selectedText = strings.escapeRegExpCharacters(selectedText);
} What do you think? Thanks :) |
This is fine, but I realized that the inconsistency bugs a little me that the |
@roblourens Thank you for your review. I took a look at that and I couldn't find a way to get selection information in the find widget. However I wonder whether users want to use a very part of text in the find widget or not when they want to seed words from the find widget for the search view. I think it makes more sense to always use the whole text in the find widget. |
…idget in SearchView
I've added the following lines to updateTextFromFindWidget method for the consistency with the regexp option. this.searchWidget.searchInput.setCaseSensitive(controller.getState().matchCase);
this.searchWidget.searchInput.setWholeWords(controller.getState().wholeWord); |
I agree that if we're in seeding from find widget case we can ignore the nearest word setting and just go with the full find input state. |
I mean, the reason that setting exists is for cases when people just want to move focus to the search view without changing its text, and this would break that, right? I guess we can try it and see how it goes? |
|
I don't think a user is going to draw a strong distinction between "the editor" and the find widget. Either way, it's going to do something in the search view that they didn't expect. |
I don't think this is right. When no words are selected in the editor, current behaviors are as follows:
When some words are selected in the editor, they will replace the search view text regardless of the setting. |
If you are describing what happens today (without your change) then that's right, and matches what I said (they leave the setting disabled if they want to not change the search view unless they select text) If you are describing what happens in the find widget with your PR, then that's not what I see, I see it always update the search view when that setting is disabled and focus is in the find widget, regardless of editor selection. |
Now I see what you concern about. (I described what happens today. ) IMO I don't concern about that because this PR changes the behavior only when the find widget is focused. I think people want to use the entire word in the find widget for the search view when they focus on the find widget. |
I don't see any reason that people want different behavior when focus is in the find widget. But, there is a solution. We can know when the find input is focused (you already check this) and we know that it is a native text input. So we can check To make it simple, we can say, if there is any selection in the find widget, take the full value. If there is no selection, don't take the value (when the setting is disabled) |
Thank you for the suggestion! I'll take a look. |
@roblourens I've updated updateTextFromFindWidgetOrSelection and updateTextFromFindWidget to check selection in the find widget and |
Looks good, but we are stabilizing for release this week so I will merge it next week. |
Thanks for your work on this! Looks like I'm a bit too late to sway the final result, but as the filer of the bug, I thought it might be worth chiming in with my 2c. TL;DR: To illustrate where the modified behavior here fails my use case:
Expected:
Actual:
The behavior that best addresses the use case I presented in the bug is to always use the full search terms in the find widget when "escalating" a failed local search to the search view. I think the key point is that the user has already specified search terms once they choose to escalate the search. As far as using the selection in the find widget in the determination of what to escalate to the search view, my gut reaction is that consistently escalating the full terms would be the least confusing behavior, though I could see a case for using a selection, if present. It's easier to pare down the terms after escalating than to retype missing portions if the unexpected thing happens for the user's use case. |
I don't see this, I see the whole string go in. I see your point but I'm just really hesitant to put stuff in the search view and trigger a new search, it could be really annoying if that's not what the user wanted. |
If that's the case, then I'm all set. It seemed like the proposal was to treat text in the find widget like editor text w.r.t. the I think this should work great for my use case and you can ignore the above. Looking forward to trying it out in the new version. |
Thank you for your comment. I'm glad to hear that! 😄 |
@roblourens |
@gmathis That was a fair assumption. I read that setting with the emphasis on "seed", and the contents of the find widget are just the relevant chunk of text, even if it's not a "word" and doesn't work exactly the same as in the editor. And your point about the whole scenario of upgrading from an editor find to a search is still good and I will continue thinking about it. Nope, that's a language server issue, it doesn't have anything to do with your PR in particular 😁 |
This PR resolves #78733.
I have added updateTextFromWidgetOrSelection method to SearchView to use search words from find widget when focused instead of using selection.