microsoft / vscode

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

Disabling "Find in Selection" removes the current text selection #204305

Closed krisutofu closed 8 months ago

krisutofu commented 8 months ago

Type: Bug

  1. Open the Find/Replace-Prompt in a file (CTRL+F)
  2. Enable "Find in Selection" (ALT+L)
  3. Select some text
  4. Disable "Find in Selection" (ALT+L)

Expected: text selection remains. Actual behaviour: text selection is replaced by the next match after it.

This is rather a design or usability bug than a technical bug. Other editors I used before VSCode allowed me to keep the text selection and did not even require to disable "Find in Selection" in order to find in a new selection. The extra step of deactivating something that is not related to the desired goals as a user is unintuitive. Therefore I typically select text and only afterwards I realize that I have to deactivate "Find in Selection" too.

On the other hand, deactivating "Find in Selection" by closing the Find/Replace-Prompt with ESC does not remove the text selection and works fine. The best workflow would be however to just select a new matching range and replace the old one with the new one, it's two steps.

It is a disadvantage for button users. I think, button users should not be disadvantaged in comparison to keyboard users.

The usual behaviour for "Find in Selection" in other editors is, that it deactivates or changes the matching range as soon as a new text selection is made. Or it deactivates the old matching range, maybe activating the new selectedrange, when a new search activity (pressing CTRL+F again) is issued. It is almost never the case that I need to copy text while I am stepping through search results. (Code clones are bad anyways and with precise regExps I can match all at once.)

Related issues: Find/Replace using selection is very messed up (closed but issue still applies) Changing the replae text in search/replace loses text selection (closed) losing text selection when toggling "Find in Selection" Entering text in find widget should not clear the selection (closed)

VS Code version: Code - OSS 1.86.0 (Commit unknown, 2024-02-01T21:58:13.529Z) OS version: Linux x64 6.7.3-zen1-1-zen Modes:

System Info |Item|Value| |---|---| |CPUs|11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz (8 x 3800)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
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: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|1, 4, 4| |Memory (System)|31.09GB (20.16GB free)| |Process Argv|--unity-launch| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|plasma| |XDG_CURRENT_DESKTOP|KDE| |XDG_SESSION_DESKTOP|KDE| |XDG_SESSION_TYPE|x11|
Extensions (16) Extension|Author (truncated)|Version ---|---|--- mermaid-markdown-syntax-highlighting|bpr|1.6.0 insert-unicode|bru|0.15.1 vscode-pandoc|Chr|0.4.5 unicode-math-input|czh|0.6.3 dhall-lang|dha|0.0.5 gitlens|eam|14.7.0 vscode-highlight|fab|1.9.0 vsc-unicode-latex|gao|1.3.0 pandoc-markdown-syntax|gar|0.0.2 render-crlf|med|1.7.0 typst-preview|mgt|0.10.7 csharp|muh|1.26.0 godot-csharp-vscode|nei|0.2.1 typst-lsp|nva|0.12.1 vt100-syntax-highlighting|Tob|1.1.0 debug|web|0.26.1
vscodenpa commented 8 months ago

Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for similar existing issues. See also our issue reporting guidelines.

Happy Coding!