Issue Type: Bug
Expected results:
The cursor is where I clicked. The window never scrolls anywhere.
Actual results:
Often enough to be annoying, but not reliably enough to describe it, the editor scrolls to a random location in the file.
I'm sorry that I can't give you more details, but this bug is EXTREMELY annoying. If I could ask for a single thing in VS Code, it would be that you drop everything else you're working on and fix this bug. VS Code is a fantastic product, and I'm sure you have lots of ideas how to make it even better. But for my daily work, the one thing that I need is this bugfix.
VS Code version: Code 1.32.0 (507312a3e3b34b084b467dfd983263bc7c9d87e0, 2019-03-06T18:52:50.880Z)
OS version: Darwin x64 18.5.0
System Info
|Item|Value|
|---|---|
|CPUs|Intel(R) Xeon(R) W-2191B CPU @ 2.30GHz (36 x 2300)|
|GPU Status|2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: enabled
rasterization: enabled
surface_synchronization: enabled_on
video_decode: enabled
webgl: enabled
webgl2: enabled|
|Load (avg)|1, 2, 2|
|Memory (System)|32.00GB (2.80GB free)|
|Process Argv||
|Screen Reader|no|
|VM|0%|
Extensions (5)
Extension|Author (truncated)|Version
---|---|---
gitlens|eam|9.5.1
python|ms-|2019.2.5558
cpptools|ms-|0.21.0
vsliveshare|ms-|0.3.1284
vscode-capnp|xmo|1.0.0
@toh-ableton I cannot reproduce this and have never experienced this issue. Is it possible that you press cmd+ or alt+ when clicking, which would cause a jump to definition?
I can reproduce the error reliably with these steps:
i18n.ts.Cmd-F and search for the string thenCmd-Shift-F search for the string indexOf (limit files to include to i18n.ts for simplicity).filter(p => extractedResources.indexOf(p) === -1)})`);. Note that the search box in the editor still contains the string then.let promises: Array<Promise<void>> = []; (just move it, do not click).findObsoleteResources.Expected results:
The view does not move. The cursor is on line 880 where I clicked.
Actual results:
The view jumps back to line 912, and the cursor is also on line 912.
Thank you for the detailed steps, but I could not reproduce. Here I am trying to reproduce, but without success:
mp4 due to gif size - Kapture 2019-03-27 at 21.24.38.mp4.zip
This is how it looks for me: vscode-issue-70306.mov.zip
oh that is horrible! Can you please try to disable all your extensions and then attempt to reproduce ?
I disabled all extensions and restarted VS Code, but no luck. I can still reproduce the bug.
It seems related to the setting "search.globalFindClipboard": true,. When I disable this setting, I can no longer reproduce the bug.
I can reproduce this, only with both search.globalFindClipboard and editor.find.globalFindClipboard set. They are interacting somehow, and the editor find value changes which causes the editor to jump.
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.
Happy Coding!
Well, now I can't reproduce this anymore in Insiders. Do you still see itI?
I can still reproduce the bug. This is what I did:
Expected: The right pane gets focused and the cursor gets positioned where I clicked
Actual: The right pane scrolls all the way to the top since the click to focus it seems to trigger a find operation for "import".
Here's a video of what it looks like for me: VSCode scroll position jump.mov.zip (bad quality due to file size constraints)
The version of VSCode I was using (in case the video is too illegible):
Version 1.35.0-insider (1.35.0-insider)
5e1f9440d280b0b04cba843df6a0032bf517a2f0
2019-05-24T05:07:33.632Z
Note that I have both globalFindClipboard options enabled:
{
"editor.find.globalFindClipboard": true,
"search.globalFindClipboard": true
}
Well, now I can't reproduce this anymore in Insiders. Do you still see itI?
Unfortunately, yes, I can still reproduce the issue using my original repro steps and both search.globalFindClipboard and editor.find.globalFindClipboard set to true.
Version 1.35.0-insider (1.35.0-insider) 2737cde4facc8411982862742f5c6cd3dabef323
I looked into this issue some more, hoping that I could contribute a fix myself. For now, I think I've found the main misunderstanding behind this bug: In https://github.com/microsoft/vscode/issues/39693#issuecomment-349831092, @rebornix states that
we read from the global find clipboard only when
(...)
Users switch from another application back to VSCode and the Find Widget is visible at the same time
(Note that this clarifies another puzzle piece necessary for reproducing this bug: The Find Widget must be visible in order to trigger the jump.)
I think that what @rebornix states it not in line with how applications normally behave on macOS. The global find clipboard should not be read on focus change, but only when invoking a search using Cmd+G. Alternatively, it would probably be acceptable if the focus change did read the global find clipboard _without triggering a search_.
I'll look some more into fixing the issue along these lines, but I know nothing about VSCode's architecture, so I'm just poking around until I maybe find something that looks like a promising way to fix this.
I've dug some more; these are my findings:
FindWidget receives focus, it reads the global find buffer through this callback and changes the FindReplaceState.FindReplaceState fires its change eventFindModel, which triggers a research (as in "search again", not "do science", I guess :))My gut feeling is that changing the "change FindReplaceState" -> "update FindModel" -> "trigger research" part is probably not a good idea.
It seems more promising to read the global find clipboard when performing a search command. The only places where one could put that functionality seem to be CommonFindController.moveToNextMatch or the public or private moveToNextMatch functions on the FindModel. I can't decide which one of these is the right one since I know too little about VSCode. If I had to guess I would pick the FindController.
Alternatively, one could create a completely new command for the Cmd+G shortcut which would read the global find clipboard, update the search state if necessary (which would trigger a re-search) or call findNextMatch otherwise.
Good investigation, I agree with your assessment. One minor thing,
When FindWidget receives focus
This happens when the editor receives focus, just mentioning that because it confused me for a bit.
I don't really know how people commonly use this feature but the way it works now doesn't seem quite right. I have to leave this one to @rebornix...
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.
Happy Coding!
Could someone please reopen this? cc. @roblourens @rebornix. Looks like the bot was a bit over-eager (or rather, the "needs more info" tag should have been removed). Thanks!
@roblourens @rebornix is there anything I can do to help move this along?
I don't really know how people commonly use this feature but the way it works now doesn't seem quite right.
I think it really boils down to what I outlined earlier:
Cmd+E: Push the selected text to the OS's global find clipboard to use it for the next search, but don't search yet.
Cmd+G: Read the OS's global find clipboard to see if its contents have changed; find the next occurrence.
On focus change: Don't do anything search-related. Especially, don't trigger a new search.
This kinda makes the "Editor › Find: Global Find Clipboard" and "Search: Global Find Clipboard" preferences obsolete: The only interaction with the clipboard should be when pressing Cmd+E and Cmd+G. I guess these could be special commands that only exist on macOS, if that fits within the cross-platform concept of VS Code.
The beauty of this feature is that I can select a word in one application and search for it in another without having to go through the copy/paste clipboard and without necessarily overwriting what I'm searching for in other applications where I don't want to search for this word: As long as I don't press Cmd+G, the global find clipboard shouldn't leak into an app. In this sense, Cmd+G is not the same as "find next": "find next" as invoked when clicking a button in the search widget shouldn't read the global find clipboard.
I think I am running into the same issue, which has caused me endless frustrations of late, the cursor seemingly jumping to random locations in my open editors.
I have found a way to consistently reproduce, if needed (in Insiders):
foo exists in both editorsbar, then scroll around a bit, away from the term foofoo. Note that the find box in editor 1 still says bar at this stagefoo, and the editor jumps to the first instance of foo that it can find.That last bit is horribly annoying, because it takes you out of context for no reason. It should update the find box to the search term used in editor 2, yes, but it should not under any circumstances jump to the first found occurrence when I simply focus on the editor, but only do this when I press CMD+G.
I just came here to report the same bug. As has been mentioned in this issue and also in #85308, the problem is related to the "global find clipboard" when running VS Code on macOS. This bug is heinously annoying and makes that feature unusable for me! I constantly lose my place in files.
Disabling "global clipboard" prevents the issue from occurring, but also disables proper clipboard behavior on macOS.
@Rebornix commented in #85308 that this behavior is connected to the editor's Auto Search 'feature' (which is confusingly named, and should be something like Auto Scroll to Matching Text).
The reason I mention it here is that there is already #60977 with some traction bemoaning other effects of Auto Search, and proposing it be adjusted.
While the specific issues aren't identical, they both involve unexpected scrolling/editor movement based on auto search, and that issue is close to the 20 upvotes needed for acceptance.
If you'd like to support that issue (and thus indirectly this one), you can do so by thumbs-upping the first post of that thread.
I have the exact same issue, super annoying. "Glad" I found others with the same experience!
Hope this get adressed, this is probably my number one complaint with my VS Code experience, which is my primary editor for most projects/languages.
@koliyo and any others who came here to support this, please remember to upvote at the first post here, and/or first post at #60977 (maybe state your reason there, since this thread is not exactly the same).
And, if the upvote policy itself wasn't clear/known to you, you can separately consider upvoting #90091 and #89652.
I can't repro in latest release.
Sorry, it indeed does still happen.
I can still reproduce it in 1.43.2:
editor.find.globalFindClipboard is enabledExpected:
Actual:
The bold part must not happen.
Edited since I missed a crucial step to reproduce. To summarize, here are the conditions that must be fulfilled to reproduce this:
editor.find.globalFindClipboard must be enabledI can also still repro this in 1.43.2.
Just wanted to update folks on this thread: I opened up a PR a while back that seems to have fixed this (and a sister issue) for me. At least one other user has also reported that it works for them.
I haven't heard back from the VSC team as to whether I need to take further action to move the PR along, so I thought I'd mention that it's a small fix, so you can easily build your own copy of VSC and cut out 3 lines to solve the issue.
So, just in case this is still driving you crazy, you can see either
Just for the record: I do find cursor movement while typing into the Find Widget useful behavior. What I find highly annoying is cursor movement when clicking into a window, what this bug is about. Now I have to choose between a feature a very much want to have and a bug that's super disruptive.
I would still prefer a proper fix for this bug rather than an option to disable a feature that coincidentally disables this bug.
@toh-ableton sounds reasonable to me.
I agree 100% with @toh-ableton. I use the cursor movement behavior a lot in other IDEs and editors, such as Qt Creator and Sublime Text. It's a little awkward with the cursor not automatically moving when I start typing into the search box.
And of course the problem was clicking into an editor pane and the cursor suddenly jumping to an unwanted position in the file, especially if I changed the search string between when I clicked out of that editor and when I clicked back in.
Agree with you all that when you just focus back into the editor, if the search term is updated by others (e.g., the global clipboard), it should not move the viewport, otherwise you lose where you were previously. Pushed a change to disable that.
Most helpful comment
I think I am running into the same issue, which has caused me endless frustrations of late, the cursor seemingly jumping to random locations in my open editors.
I have found a way to consistently reproduce, if needed (in Insiders):
fooexists in both editorsbar, then scroll around a bit, away from the termfoofoo. Note that the find box in editor 1 still saysbarat this stagefoo, and the editor jumps to the first instance offoothat it can find.That last bit is horribly annoying, because it takes you out of context for no reason. It should update the find box to the search term used in editor 2, yes, but it should not under any circumstances jump to the first found occurrence when I simply focus on the editor, but only do this when I press CMD+G.