microsoft / vscode

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

bracket navigation ("go to bracket" & "expand selection"...) in plain text files is broken #149033

Closed Hamido-san closed 1 year ago

Hamido-san commented 2 years ago

Issue Type: Bug

  1. in VSCode, hit [ctrl+N] (File → New Text File)
  2. notice the language mode button on the status bar (↘) says Plain Text
  3. insert following text:
    outside text (inside text)
    outside text [inside text]
    outside text {inside text}
  4. put cursor on any bracket, hit [F1] (command palette) → go to bracket
    result: no change in cursor location (broken in the latest VSCode update)
    expected: cursor should jump to matching bracket
  5. put cursor on any instance of the text "inside", hit [F1] (command palette) → expand selection
  6. notice selection around "inside"
  7. use expand selection again
    result: selection expands to whole line (broken in the latest VSCode update)
    expected: repeated uses of expand selection should select
    • "inside"
    • "inside text"
    • "{inside text}"
    • and then the whole line

VS Code version: Code 1.67.0 (57fd6d0195bb9b9d1b49f6da5db789060795de47, 2022-05-04T12:06:02.889Z) OS version: Windows_NT x64 10.0.19044 Restricted Mode: No

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-2500K CPU @ 3.30GHz (4 x 3311)| |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
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|undefined| |Memory (System)|15.98GB (8.15GB free)| |Process Argv|--crash-reporter-id 35ee7a86-9a48-4fb6-9fd8-8118916441ec| |Screen Reader|no| |VM|57%|
Extensions (23) Extension|Author (truncated)|Version ---|---|--- astro-vscode|ast|0.16.1 calva|bet|2.0.272 clj-kondo|bor|2022.4.25 insert-unicode|bru|0.13.3 docs-markdown|doc|0.2.110 es7-react-js-snippets|dsz|4.4.3 gitlens|eam|12.0.6 prettier-vscode|esb|9.5.0 url-encode|fle|1.1.0 code-runner|for|0.11.7 selected-lines-count|gur|1.4.0 vscode-drawio|hed|1.6.4 escape-regexp|kir|1.0.0 git-graph|mhu|1.30.0 vetur|oct|0.35.0 subtitles-editor|pep|1.1.6 material-icon-theme|PKi|4.17.0 java|red|1.6.0 vscode-autohotkey|sle|0.2.2 svelte-vscode|sve|105.16.0 vscodeintellicode|Vis|1.2.20 vscode-java-pack|vsc|0.22.4 vuetify-vscode|vue|0.2.0
hediet commented 2 years ago

Workaround for now:

Add this to your settings:

"[plaintext]": {
    "editor.language.colorizedBracketPairs": [
        ["{", "}"],
        ["(", ")"],
        ["[", "]"]
    ]
},

If you don't like the colors, you can turn them off:

"editor.bracketPairColorization.enabled": false

I'm working on a fix so that matching works independently of colorizedBracketPairs.

Hamido-san commented 2 years ago

If you don't like the colors, you can turn them off: "editor.bracketPairColorization.enabled": false

I also added "editor.guides.highlightActiveBracketPair": false to keep the colors faded

Thanks for the tip, and keep up the good work

Hamido-san commented 2 years ago

I'm working on a fix so that matching works independently of colorizedBracketPairs.

Well, to think about it, defining the bracket pairs once and having both navigation & colorization work consistently is pretty good design. In this case (plain text) all we need seems to be some default settings to maintain the previous behavior. Right?

hediet commented 2 years ago

Well, to think about it, defining the bracket pairs once and having both navigation & colorization work consistently is pretty good design.

The idea is that colorized bracket pairs must be a subset of all bracket pairs. Then they can use the same bracket structuring, but only some bracket pairs are colorized.

Hamido-san commented 2 years ago

Yeah, if that level of flexibility is needed, then making the one settings.json a bit more verbose wouldn't hurt too much

RedCMD commented 1 year ago

The idea is that colorized bracket pairs must be a subset of all bracket pairs. Then they can use the same bracket structuring, but only some bracket pairs are colorized.

would it be possible for extensions to define this behaviour? so we could have colours disabled by default for certain brackets but not others while keeping bracket pair matching working for all

hediet commented 1 year ago

Fixed with https://github.com/microsoft/vscode/issues/170497