microsoft / vscode

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

Regex replace matches without consuming and leaks groups between matches #234067

Open LinusKardellInfobric opened 4 hours ago

LinusKardellInfobric commented 4 hours ago

Type: Bug

  1. Create a new directory
  2. Create a text file in it with the contents abcde=fghijkl=mnopq
  3. Go to the search tab
  4. Enable regex
  5. Enter replacement $1 = $2
  6. Enter search term ([^= ])(?:=)([^\n= ])

When doing this, the replacements end up like this:

Image

I would expect the result to be abcde = fghijkl = mnopq.

VS Code version: Code 1.95.3 (f1a4fb101478ce6ec82fe9627c43efbf9e98c813, 2024-11-13T14:50:04.152Z) OS version: Linux x64 6.4.0-150600.23.25-default Modes:

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 7 1700X Eight-Core Processor (16 x 1996)| |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: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
webnn: disabled_off| |Load (avg)|1, 2, 2| |Memory (System)|62.73GB (35.48GB free)| |Process Argv|--disable-extensions . --crash-reporter-id 3e86f7c6-6835-4d7d-9a0f-6ac8343df962| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|plasma5| |XDG_CURRENT_DESKTOP|KDE| |XDG_SESSION_DESKTOP|KDE| |XDG_SESSION_TYPE|x11|
Extensions disabled
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 vscrpc:30673769 a9j8j154:30646983 962ge761:30959799 pythonnoceb:30805159 asynctok:30898717 pythonmypyd1:30879173 2e7ec940:31000449 pythontbext0:30879054 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 bdiig495:31013172 dvdeprecation:31068756 dwnewjupyter:31046869 2f103344:31071589 impr_priority:31102340 nativerepl1:31139838 pythonrstrctxt:31112756 nativeloc1:31134641 cf971741:31144450 iacca1:31171482 notype1cf:31157160 5fd0e150:31155592 dwcopilot:31170013 stablechunks:31181875 ```
RedCMD commented 2 hours ago

cannot confirm Image

LinusKardellInfobric commented 1 hour ago

Try closing all the tabs and searching again (editing the search term slightly and undoing the edit). It seems like it doesn't happen if the file is currently open.