microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.23k stars 28.56k forks source link

Search pane: F4 after editing should visit the next search entry #206511

Open lukstafi opened 6 months ago

lukstafi commented 6 months ago

Type: Bug

Current behavior:

The behavior I expect:

My impression is that the search pane loses selection on edits even if the edit does not make the selected entry disappear. But it would be great for my workflow to not lose the rough selection position among the search entries even if the selection would to disappear. The previous entry to the one that disappeared should become selected, so that the following F4 would find the next entry's position.

Non-issues: this issue is about navigating the search locations solely with F4 (or the corresponding command), not about what happens when someone presses Ctrl+Shift+F again etc.

VS Code version: Code 1.86.2 (903b1e9d8990623e3d7da1df3d33db3e42d80eda, 2024-02-13T19:40:56.878Z) OS version: Windows_NT x64 10.0.22631 Modes: Remote OS version: Linux x64 5.15.90.1-microsoft-standard-WSL2 Remote OS version: Linux x64 5.15.90.1-microsoft-standard-WSL2 Remote OS version: Linux x64 5.15.90.1-microsoft-standard-WSL2

System Info |Item|Value| |---|---| |CPUs|12th Gen Intel(R) Core(TM) i5-12500H (16 x 3110)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|15.73GB (3.35GB free)| |Process Argv|--crash-reporter-id 567907ee-4b0b-4e08-b1b4-a7074f51305a| |Screen Reader|no| |VM|0%| |Item|Value| |---|---| |Remote|WSL: Ubuntu| |OS|Linux x64 5.15.90.1-microsoft-standard-WSL2| |CPUs|12th Gen Intel(R) Core(TM) i5-12500H (16 x 3110)| |Memory (System)|7.63GB (6.05GB free)| |VM|0%| |Item|Value| |---|---| |Remote|WSL: Ubuntu| |OS|Linux x64 5.15.90.1-microsoft-standard-WSL2| |CPUs|12th Gen Intel(R) Core(TM) i5-12500H (16 x 3110)| |Memory (System)|7.63GB (6.05GB free)| |VM|0%| |Item|Value| |---|---| |Remote|WSL: Ubuntu| |OS|Linux x64 5.15.90.1-microsoft-standard-WSL2| |CPUs|12th Gen Intel(R) Core(TM) i5-12500H (16 x 3110)| |Memory (System)|7.63GB (6.05GB free)| |VM|0%|
Extensions (19) Extension|Author (truncated)|Version ---|---|--- tsl-problem-matcher|amo|0.6.2 find-and-transform|Art|5.0.1 clipboard-manager|Edg|1.5.0 pythonsnippets|frh|1.0.2 vscode-ptx-syntax|gka|1.0.0 better-cpp-syntax|jef|1.17.2 vsc-python-indent|Kev|1.18.0 jupyter-keymap|ms-|1.1.2 remote-containers|ms-|0.348.0 remote-wsl|ms-|0.86.0 gitlens|eam|14.8.2 vscode-pull-request-github|Git|0.80.1 navi-parens|luk|1.3.2 vocaml|luk|1.1.2 live-server|ms-|0.4.13 ocaml-platform|oca|1.17.1 r|REd|2.8.2 vscode-ocaml-expect-inline|rel|0.7.2 ocamlformat-auto-completion|tar|0.1.1 (1 theme extensions excluded)
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscoreces:30445986 vscod805cf:30301675 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:30899288 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pyreplss1:30897532 pythonmypyd1:30879173 pythoncet0:30885854 pythontbext0:30879054 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 pydisww1:30959800 d34g3935:30971562 edj9j583:30969295 fegfb526:30961430 7j2b6412:30969109 e3gdj431:30958358 ```
VSCodeTriageBot commented 6 months ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.87.0. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

lukstafi commented 6 months ago

It would also be nice, although a bit less ergonomic, if the same-numbered position becomes selected when a search entry disappears due to my edit. Then I could do one back-and-forth (shift+F4, F4) to navigate to the next entry.

andremmsilva commented 6 months ago

Hi! I'd like to work on this if it is possible. I am new to the project but would love to help out

Thanks :)

andreamah commented 6 months ago

Yes of course! I believe that we are updating the text results from the current editor on change, which happens here: https://github.com/microsoft/vscode/blob/0b208e353d259b25ac2921d408d45823562c9bb2/src/vs/workbench/contrib/search/browser/searchModel.ts#L524-L537

However, the search view, you can see that selectNextMatch requires an element in the tree to be selected: https://github.com/microsoft/vscode/blob/dff6d9f391dd448ca92463e755ca34f46fcc5843/src/vs/workbench/contrib/search/browser/searchView.ts#L1030

So then I'd imagine that we'd need to find a way to say "when we refresh results due to a model change, just shift the selection to the previous item in the tree". Currently, the selection on the tree just disappears, causing F4 to just start from the top.

silverqx commented 2 months ago

I'm also struggling with this problem (a lot), I want to tell that this is a Regression, this problem doesn't exist in previous vscode versions, it started ~v1.70 (I don't remember exactly). For me, this is one of the most annoying issues.

silverqx commented 3 weeks ago

Now I tried to download VScode 1.60.2, unpacked zip and executed it like .\Code.exe --user-data-dir H:\Downloads\_tmp\vscode_1.6_data\profile --extensions-dir h:\Downloads\_tmp\vscode_1.6_data\extensions

I tried test this regression, it doesn't exist in this older version, if you delete lines above or below the currently selected search result, it just simply selects the next entry, it doesn't care about cursor positions in the editor.

Here is a video of how it worked before this regression: https://youtu.be/UlOlBNl5QRo

silverqx commented 1 day ago

Is no one really interested in this? I'm affected by this bug every day. 😔

silverqx commented 23 hours ago

I would really appreciate if someone could review and merge that finished PR. #209228 😁