microsoft / vscode

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

Inline "Revert Change" makes a mess of code #185321

Open Steve-Mcl opened 1 year ago

Steve-Mcl commented 1 year ago

Type: Bug

  1. Make a change to a file
  2. Click the change marker in the lefthand gutter to reveal the local working changes
  3. click the "Revert Change" icon/button in the inline toolbar (on the right hand side of the header)
  4. The revert action generally makes a mess or puts the revered code in the wrong place

VS Code version: Code 1.79.2 (695af097c7bd098fbf017ce3ac85e09bbc5dda06, 2023-06-14T08:57:04.379Z) OS version: Windows_NT x64 10.0.22621 Modes:

System Info |Item|Value| |---|---| |CPUs|11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz (8 x 2803)| |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
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|undefined| |Memory (System)|15.65GB (4.90GB free)| |Process Argv|| |Screen Reader|no| |VM|0%|
Extensions (42) Extension|Author (truncated)|Version ---|---|--- emojisense|bie|0.10.0 vscode-tailwindcss|bra|0.9.11 path-intellisense|chr|2.8.4 vscode-postgres|cko|1.4.2 vscode-postgresql-client2|cwe|6.5.3 vscode-eslint|dba|2.4.0 gitlens|eam|14.0.0 nunjucks-template|ese|0.5.1 vscode-terminals|fab|1.15.0 copilot|Git|1.89.156 copilot-chat|Git|0.2.1 copilot-labs|Git|0.14.884 remotehub|Git|0.58.0 vscode-github-actions|git|0.25.7 vscode-pull-request-github|Git|0.66.1 vscode-mocha-test-adapter|hbe|2.14.1 vscode-test-explorer|hbe|2.21.1 vscode-markdown-footnote|hou|1.0.0 vscode-favorites|how|1.11.0 vscode-edit-csv|jan|0.7.6 vscode-peacock|joh|4.2.2 formate|Mik|1.2.1 js-interactive|Moh|1.1.11 data-workspace-vscode|ms-|0.5.0 mssql|ms-|1.19.1 isort|ms-|2022.8.0 python|ms-|2023.10.1 vscode-pylance|ms-|2023.6.20 remote-containers|ms-|0.295.0 remote-ssh|ms-|0.102.0 remote-ssh-edit|ms-|0.86.0 remote-wsl|ms-|0.79.5 azure-repos|ms-|0.34.0 remote-explorer|ms-|0.4.0 remote-repositories|ms-|0.36.0 test-adapter-converter|ms-|0.1.8 vscode-thunder-client|ran|2.7.7 vscode-yaml|red|1.13.0 partial-diff|ryu|1.4.3 code-spell-checker|str|2.20.5 svelte-vscode|sve|107.5.1 volar|Vue|1.6.4
Steve-Mcl commented 1 year ago

Demo: (VS Code version: Code 1.79.2)

https://github.com/microsoft/vscode/assets/44235289/b2de6640-577a-4558-aa85-40ea5f351127

Demo: Insiders - ZERO plugins/extentions, fresh install

Version: 1.80.0-insider (user setup)
Commit: 0e9c2fa760932b13f81516aff15f2b0112aa6eeb
Date: 2023-06-16T05:33:38.323Z
Electron: 22.5.7
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.22621

https://github.com/microsoft/vscode/assets/44235289/d346309b-5556-4cfe-aa46-26dd686c0628

Steve-Mcl commented 1 year ago

FYI, I have updated to latest this morning:

Version: 1.79.2 (user setup)
Commit: 695af097c7bd098fbf017ce3ac85e09bbc5dda06
Date: 2023-06-14T08:57:04.379Z
Electron: 22.5.7
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.22621

This is still an issue:

https://github.com/microsoft/vscode/assets/44235289/f55ded05-c841-4194-a826-df8ca00c09b0

Steve-Mcl commented 11 months ago

FYI, still occurs on 1.80.1

https://github.com/microsoft/vscode/assets/44235289/b0119939-f5f7-49e4-b701-880b08345d4b

ryanhyzhu commented 6 months ago

still occurs on 1.85.0 exact desc: #114068 vcs is totally unusable

lszomoru commented 6 months ago

I have reopened https://github.com/microsoft/vscode/issues/114068. Thanks for pointing out the repro.

lszomoru commented 6 months ago

@hediet, here are some more scenarios in which the diff algorithm is causing "revert change" to make incorrect edits.