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
Find/Replace using selection is very messed up #27083
Comments
Works fine for me, I don't understand the problem. Can you be more specific or include a screenshot? |
Yeah, I can probably give you a video.
It is very broken, actually.
I'll get back to you.
…On Mon, May 22, 2017 at 11:43 AM, Rob Lourens ***@***.***> wrote:
Works fine for me, I don't understand the problem. Can you be more
specific or include a screenshot?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#27083 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAo6ZYWGyF_6bUs3yC0RYu3EUVfgB9Tvks5r8ddKgaJpZM4NirPl>
.
|
I'm having a similar issue. I've documented the problem in this Stack Overflow post. Very similar issue with the find/replace tool. |
Still works fine for me. Can you try in Insiders? A gif/video would be great. |
Here's a video: https://1drv.ms/v/s!AuxdNgJmWJNgl9gePfXS47vKv-pVWw. I haven't tried Insiders, but I'm running 1.12.2 (latest last I checked) on Ubuntu. |
Ah I see. We used to enable find in selection automatically when opening the find widget with a selection, but it was too easy to trigger accidentally and produced a lot of complaints. You probably want to set What's happening is that you make a selection, open the find widget, then do a search for Hope that helps. |
Works for me! I'll update the SO answer, Hopefully we can get the word out of |
I've added |
The problem in the video is ONE of the issues, yes.
However...
*I can't find 'editor.find.autoFindInSelection' in Settings and when I set
it, nothing happens. (I have the latest and greatest VSCode)*
Another thing that happens is:
Even when you have the 'find in selection' icon selected and it replaces
text fine in that selection, you can't repeat the step with another
selection.
Steps:
1. Select some text
2. CTRL-H
3. type in FIND+REPLACE text
4. notice that selection icon is not selected - select it
5. maybe re-select the text (basically, problem in the video)
6. CTRL-ALT-Enter
...
6. NOW...go back to the document with the mouse (I tend to not use the
mouse too often)
7. select more lines that contain the text to find
8. CTRL-H
9. No Results!!! arrrggh!
10. but...immediately SHIFT-TAB to the FIND box (above the REPLACE box)
11. Magically, it works! Your selection is now correct and the replacements
to be made are correct
It seems the focus event on the FIND box triggers a new selection while
CTRL-H doesn't the 2nd time since the focus is set to the REPLACE box.
This is borked. Makes speedy development impossible.
…-Jeff
On Wed, Jun 7, 2017 at 12:21 PM, Rob Lourens ***@***.***> wrote:
Ah I see. We used to enable find in selection automatically when opening
the find widget with a selection, but it was too easy to trigger
accidentally and produced a lot of complaints. You probably want to set
"editor.find.autoFindInSelection": true which will make it work the way
you expect.
What's happening is that you make a selection, open the find widget, then
do a search for ., not in the selection. When you do a search, it selects
each result. So then when you go press the find in selection button, it
doesn't have the original selection anymore.
Hope that helps.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#27083 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAo6ZQvOnAiwbg2Wyzw5a7Nj_g3QLkbyks5sBvhTgaJpZM4NirPl>
.
|
@jmounce are you using Stable? We didn't release 1.13 yet (it's coming this week) so right now you can play with this feature in Insider. |
Ah I didn't realize that was a brand new option in 1.13, apologies. |
I've tried with |
I confirm this feature implementation doesn't currently work as expected and is very buggy and inconsistent. I'm surprised there are not more complains and feedback about it as if nobody encountered this issue in their workflow. Steps to reproduce (bug 1)The bug occurs when you try to select one and only one line.
Good luck to get out of this loop trying to do a simple thing. WorkaroundIf
BUGS 2
ResultsYou can not directly use the replace field to only run the replace command on the selected lines. Workaround 2Just put the focus on the search field then the selected lines will trigger the Conclusion
This find in selection feature will play with your nerve when you only want to do what is expected:
For now, you'd better set Bonus Bug 3The
I would say those are severe bugs since it is a basic feature that every user has to use in its workflow from time to time. |
Thanks for the detailed writeup :) With |
@roblourens How is Replace All supposed to work with find in selection? I don't so much care about what I have to do to enable "find in selection", but it makes no sense to me that even after it is enabled hitting "replace all" will replace every match in the file: (please open gif in new tab if too tiny to see) EDIT: Looks like Github has truncated the gif a few months after I first posted this comment, it looks like a 500 ms loop of nonsense now. The original full link to the gif is: https://rlgvlw.by3302.livefilestore.com/y4mXh_4dIcv6Huc1vuGJmJ7rfHzmz7sDC_mPeAwhssnYrKOvLiER7sP9iMkubRJOPUkCpyB5GuLgDmaVTX6GLPot6L1QI5edoJniMzJrjsEG08a-CX2S5mJ4RVAgo2nzRCGnvEp5aRb_VuW3oxrKrBwn6X8mchkBsa64p3QLQMLEuzD-pjWiwaFloIHV-3vjufVhp9Z4Ffjl_UCkoZ4qg93eA/2017-06-15_01-15-30.gif?psid=1 |
I'm also having trouble with changing the selection blocks when using Find/Replace in Selection. It does not change the search region automatically after I've selected a different block of text. For example, if one has two blocks of code with an unrelated string in between, the experience is lacking. |
One simple bug I see is: "editor.find.autoFindInSelection": true does not work for Replace The Find in Selection icon is highlighted but the highlight in the editor is not there and replace replaces all entries. Workaround: Press Alt+L (once), or press Ctrl+F before pressing Ctrl+H Under these conditions the find selection editor highlight IS respected and is kept after doing replace all. The fact the the icon is highlighted in itself seems wrong, it should be tied 1:1 to the current find mode and getting out of sync should not be possible. |
I confirm that find and replace in selection is inconsistent--whether When you toggle in-selection mode in the S&R dialog, the target replacements might or might not be limited to the selection. In addition, the selected text becomes unselected most of the time. What's weird to me is that it also happens in Atom. I got so fed up with it there that I downloaded Code today--only to find exactly the same behavior! Is that a clue to the cause? |
@aztecrex - That may well be a clue. I have also seen hints that some or all of this behavior is modeled after Sublime Text. I think the idea is that the "Find and Replace in Selection" paradigm many of us are used to or expecting is somehow outdated and inferior. Incidentally, I have been trying to evaluate both Atom and VS Code. Both are wonky (to my taste) in this regard, but at least in Atom, the dialog always includes Replace, so there isn't the issue of something working differently depending on whether you started with Ctrl+F or Ctrl+H. And the "within current selection" option is at least very obvious, and "sticky" from one invocation to the next. |
The main problem is that F/R box doesn't update its find selection context until you focus on the find field. The moment you do that, find count updates and you can do the replacement. So the only way to make speedy multiple selection replacements is to focus the find field every time you want to make a replacement in the selected text. Voila. It's a bug, that needs fixing, but this mitigates it rather nicely. |
@roblourens , @AdamBJ |
Let's try to fix issues mentioned above one by one ;)
|
Alt + L |
Above changes will be shipped in tomorrow's Insiders. Can anyone help me understand if I miss anything/bug ? |
@chambead thanks for your feedback, really insightful.
let's track this issue in #50567. Once the Find In Selection is toggled off, we will do another search in the whole document and move the selection to the nearest match so the next Find In Selection toggle can not bring back the search range. That's what we need to investigate into.
Feel free to create a feature request for Search Viewlet, Find Widget is focusing on single file.
We can resize the find widget horizontally but not vertically.
If we set |
Just found this issue and tested the insiders build and I found two main problems:
Also, don't know if this has been mentioned, but it's the thing that bugs me the most:
The only reason it should change is if I closed the dialog then tried to find again with no selection, and even then, I'm not sure if it's better to just use the previous selection or the active line in those cases. Another way to tackle it might be to allow starting the find dialog in different modes? For example: ctrl+f = regular, ctrl+alt+f = start with selection? I think I'm going to make myself some macros for this. I looked to see if this existed btw, and found a kind of confusing "Find with Selection" shortcut. I feel like maybe it should be called "Seed Find from Selection", though that's minor complaint. Btw, does anything like this exist to seed the replace text? Would be really useful. I could make my workflow:
|
even after minutes could not replace inside the selection. |
I think I have found another workaround. It seems to me that the find in selection works if I highlight my selection from the end to the beginning and leave the cursor before the selection. Otherwise, the selection jumps to whatever is next. I still think that this is wrong behavior, but I hope it might save some people some headache. |
i have to add that lately, still with 1.27.2, i am able to replace inside selection without problems. not sure what makes the difference between back than and now. i assume my problem was related to the specific file and file format (typescript, jsx in the problematic case). |
This is definitely so horrifically broken it's laughable. I've struggled and struggled to replace in selection and it's infuriating. I will try with the |
Considering that the issue is 2 years old I think it's better to open PR and fix everything rather than waiting for devs to react ... |
One thing I'm seeing that I didn't see mentioned here is that when I CTRL+H to replace, with auto find in selection set to true, and then I hit TAB to move from the "Find" field to the "Replace" field, it instead auto completes text in the editor. As if the focus isn't truly in the "Find" field to begin with. |
I have another problem with multi-cursor select. It replaces only in the "first" selection (The one where the original cursor is). Should I report a new issue? https://drive.google.com/open?id=1FfTJ5pk09iU5V-8Xh1NzLeCMFxx_lH6B |
I think the option
|
i don't think there's a need for a different findInSelection option. It never makes sense to 'find in selection' if the find input is initialized with the value of the selection. there's no need for an option to say 'always do something that never makes any sense', just don't do the broken thing. visual studio proper has always done the right thing here, choosing 'current document' instead of 'selection' when doing a ctrl-f3. |
If you are referring to my soution, I didn't propose any such option that does both things at the same time, as it wouldn't make sense, as you suggest. I have included
|
Thanks all for your contribution to this topic and thanks @xates for your proposal, it makes perfect sense that for a lot of time you only want to auto find in selection when it's across multiple lines. It used to be like what's being proposed above but I think years ago when we hear the complains about auto find in selection not working when searching in long lines, we relax it a little bit to support all cases. But it definitely break the experience for single line, especially when using with From next weeks' Insiders, |
I appreciate all the work and attention that has gone into this, but I don't think I will ever be truly comfortable with Find/Replace in VS Code. The issue for me is that the "find in selection" button looks and feels like a toggle switch, not a trigger (or "fire button"). If you flip a toggle switch from one position to the other, and then back to the original position, it should be as though you had never flipped the switch at all. With this mental model, it is always a shock and a disappointment when flipping the switch irreversibly destroys my carefully crafted manual selection. |
Steps to Reproduce:
The text was updated successfully, but these errors were encountered: