VSCodeVim / Vim

:star: Vim for Visual Studio Code
http://aka.ms/vscodevim
MIT License
13.89k stars 1.31k forks source link

Undo broken with new VS Code #8157

Closed marchbox closed 1 year ago

marchbox commented 1 year ago

Type: Bug

I just upgraded to VS Code 1.74.0 today, and started noticing an issue with undo command ("u") in Vim. It appears to only go back 2-3 iterations (my current Vim: History setting is "50"). And if I hit CTRL+Z, it first undoes what "u" just undid, then start actually undoing, e.g.

Here is my VS Code info: Version: 1.74.0 (Universal) Commit: 5235c6bb189b60b01b1f49062f4ffa42384f8c91 Date: 2022-12-05T16:43:37.594Z (2 days ago) Electron: 19.1.8 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Darwin arm64 21.6.0 Sandboxed: No

Extension version: 1.24.3 VS Code version: Code 1.74.0 (Universal) (5235c6bb189b60b01b1f49062f4ffa42384f8c91, 2022-12-05T16:43:37.594Z) OS version: Darwin arm64 21.6.0 Modes: Sandboxed: No

System Info |Item|Value| |---|---| |CPUs|Apple M1 Max (10 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
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
webgpu: disabled_off| |Load (avg)|2, 2, 2| |Memory (System)|64.00GB (32.10GB free)| |Process Argv|--crash-reporter-id 934e8b32-9713-4d8f-957f-354420e03177| |Screen Reader|yes| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vsreu685:30147344 python383cf:30185419 vspor879:30202332 vspor708:30202333 vspor363:30204092 vslsvsres303:30308271 pythonvspyl392:30443607 vserr242cf:30382550 pythontb:30283811 vsjup518:30340749 pythonptprofiler:30281270 vsdfh931:30280409 vshan820:30294714 vstes263cf:30335440 vscoreces:30445986 pythondataviewer:30285071 vscod805cf:30301675 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 cmake_vspar411:30581797 vsaa593:30376534 pythonvs932:30410667 cppdebug:30492333 vsclangdc:30486549 c4g48928:30535728 dsvsc012:30540252 azure-dev_surveyone:30548225 pyindex848:30577860 nodejswelcome1:30587005 2e4cg342:30602488 gswce1:30612156 iaj6b796:30613358 dbltrim-noruby:30604474 89544117:30613380 fim-prod:30623723 ejf25101:30620729 ```
homburg commented 1 year ago

I tried debugging on the extension today, and I seemed to get a lot of history resets from this line: https://github.com/VSCodeVim/Vim/blob/e7075ad72e5b31b980ab52e9881b2b6a7b3bd673/extensionBase.ts#L635

Just from u-presses

Eg. call trace

new UndoStack (/Users/thomas/src/github.com/VSCodeVim/vim/src/history/historyTracker.ts:238:12)
    at new HistoryTracker (/Users/thomas/src/github.com/VSCodeVim/vim/src/history/historyTracker.ts:417:4)
    at new VimState (/Users/thomas/src/github.com/VSCodeVim/vim/src/state/vimState.ts:336:2)
    at new ModeHandler (/Users/thomas/src/github.com/VSCodeVim/vim/out/extension.js:63348:25)
    at Function.create (/Users/thomas/src/github.com/VSCodeVim/vim/out/extension.js:63314:29)
    at ModeHandlerMapImpl.getOrCreate (/Users/thomas/src/github.com/VSCodeVim/vim/src/mode/modeHandlerMap.ts:40:44)
    at getAndUpdateModeHandler (/Users/thomas/src/github.com/VSCodeVim/vim/extensionBase.ts:47:23)
    at /Users/thomas/src/github.com/VSCodeVim/vim/extensionBase.ts:264:5
    at Queue.start (/Users/thomas/src/github.com/VSCodeVim/vim/node_modules/queue/index.js:145:1)
    at Queue.<computed> [as push] (/Users/thomas/src/github.com/VSCodeVim/vim/node_modules/queue/index.js:59:1)
    at TaskQueue.enqueueTask (/Users/thomas/src/github.com/VSCodeVim/vim/out/extension.js:66815:24)
    at /Users/thomas/src/github.com/VSCodeVim/vim/extensionBase.ts:260:10

I am running vscode 1.75.1, haven't tried comparing with an older vscode version

homburg commented 1 year ago

Made an extension build with that line commented out: vim-1.24.3-test-undo-issue.vsix.zip from (https://github.com/homburg/Vim-1/pull/1/files)

I can't reproduce the issue with this build. Curious to see how it works for others.

Obviously would need a real fix other than just removing that feature.

ianchanning commented 1 year ago

Something I just realised is that the released version 1.24.3 is from Nov 7th, so at least a month before this issue got reported.

ianchanning commented 1 year ago

My version info:

Version: 1.75.1 Commit: 441438abd1ac652551dbe4d408dfcec8a499b8bf Date: 2023-02-08T21:35:30.018Z Electron: 19.1.9 Chromium: 102.0.5005.194 Node.js: 16.14.2 V8: 10.2.154.23-electron.0 OS: Linux x64 6.0.12-76060006-generic Sandboxed: No

Stratovarius93 commented 1 year ago

@magdyamr542 it's worked to me !!!

deimosfr commented 1 year ago

Same for me! And this workaround worked for me: https://github.com/VSCodeVim/Vim/issues/8157#issuecomment-1426704638

aromeronavia commented 1 year ago

this comment worked for me! Make sure to modify your user settings, not global settings https://github.com/VSCodeVim/Vim/issues/8157#issuecomment-1426704638

moseslucas commented 1 year ago

(https://github.com/VSCodeVim/Vim/issues/8157#issuecomment-1426704638)

This comment worked for me 🍻 Cheers mate

regohiro commented 1 year ago

https://github.com/VSCodeVim/Vim/issues/8157#issuecomment-1426704638

That works, but the native undo only undoes one time of the macro. Example: Screen Recording 2023-02-18 at 12 09 11 (2)

igniscyan commented 1 year ago

(https://github.com/VSCodeVim/Vim/issues/8157#issuecomment-1426704638)

This comment worked for me 🍻 Cheers mate

This isn't really a solution. It's just opting to use vscode's native undo rather than the undo tree that the plug-in is supposed to have.

polidore commented 1 year ago

This is killing me.

igniscyan commented 1 year ago

This is killing me.

Use the nvim extension. Seems this project isn't being maintained anymore.

polidore commented 1 year ago

I played around with it, but i commonly do remote development in SSH and WSL.. it just seems like too much complexity.

On Sat, Feb 18, 2023 at 11:40 AM Brandon Clark @.***> wrote:

This is killing me.

Use the nvim extension. Seems this project isn't being maintained anymore.

— Reply to this email directly, view it on GitHub https://github.com/VSCodeVim/Vim/issues/8157#issuecomment-1435725014, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABFS4PS53L3QDPC4UPR2GDWYECRRANCNFSM6AAAAAASXO7S4Y . You are receiving this because you commented.Message ID: @.***>

bitmaks commented 1 year ago

Having this issue as well

comonadd commented 1 year ago

Same issue after update to newest version.

ctstewart commented 1 year ago

I'm also having this issue. It seems to specifically "reset" my undos when I save the file. It's incredibly frustrating. I'm almost tempted to switch to a different IDE because of this.

druidpwnz commented 1 year ago

The same problem appears probably due Live Server extension.

Will-Low commented 1 year ago

@druidpwnz - What's your reasoning for thinking so? Did you come across something?

huyz commented 1 year ago

I'm almost tempted to switch to a different IDE because of this.

@ctstewart That makes little sense. Just downgrade until they can fix it. Why would you waste time to switch to another IDE for a temporary issue?

weiying-chen commented 1 year ago

@huyz I switched to another editor (Helix), not because this is a temporary issue, but because it made me realize that modal editing is an afterthought in VS Code (despite this extension being awesome). And these issues will keep appearing without being a priority for VS Code.

But that's just me (modal editing is the most important part of my workflow). I'm sure downgrading is just fine for most people, as you mentioned.

druidpwnz commented 1 year ago

@druidpwnz - What's your reasoning for thinking so? Did you come across something?

I'm sorry, it just so happened that for a while after turning off this extension undo/redo worked fine, and it was the last extension I installed for a long time.

lperson commented 1 year ago

I give up. I uninstalled the vim extension.

albicasty commented 1 year ago

As someone previously mentioned, I'm using nvim extension. So far so good

Il Lun 20 Feb 2023, 21:55 lperson @.***> ha scritto:

I give up. I uninstalled the vim extension.

— Reply to this email directly, view it on GitHub https://github.com/VSCodeVim/Vim/issues/8157#issuecomment-1437533785, or unsubscribe https://github.com/notifications/unsubscribe-auth/AE5YMWSARO4JXBMVMHVKMHDWYPK2XANCNFSM6AAAAAASXO7S4Y . You are receiving this because you commented.Message ID: @.***>

lperson commented 1 year ago

@albicasty do you know if it would be necessary to install nvim in a dev container?

ddnomad commented 1 year ago

@albicasty do you know if it would be necessary to install nvim in a dev container?

I'd assume so yeah

abid-mujtaba commented 1 year ago

I just installed nvim in WSL-2, vscode-neovim extension, and was able to get it to work from a devcontainer with nothing extra in the container.

expelledboy commented 1 year ago

Still broken then... to summarize

Solution 1.

    "vim.normalModeKeyBindingsNonRecursive": [
        // FIX https://github.com/VSCodeVim/Vim/issues/8157#issuecomment-1426704638
        // Wait for new release, else we should migrate to using vscode-neovim extension
        { "before": [ "u" ], "commands": [ "undo" ] },
        { "before": [ "c-r" ], "commands": [ "redo" ] }
    ],

Solution 2.

Solution 3.

Solution 4.

iddm commented 1 year ago

That's enough for me; I am downgrading to 1.72.2 or 1.73, whichever works. It is such a shame that Microsoft doesn't get a chance to fix it for such a long time. This is like the most basic text editor operation in the, perhaps, most widely used vscode extension.

UPD: I confirm it works in 1.73.1

polidore commented 1 year ago

i just installed neovim for windows and vscode-neovim and i'm able to do "remote" development in WSL no problem. seems a bit snappier too.

On Mon, Feb 20, 2023 at 8:54 PM Abid H. Mujtaba @.***> wrote:

I just installed nvim in WSL-2, vscode-neovim extension, and was able to get it to work from a devcontainer with nothing extra in the container.

— Reply to this email directly, view it on GitHub https://github.com/VSCodeVim/Vim/issues/8157#issuecomment-1437788638, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABFS4OYG4E7DHUT5PWAFVLWYQU55ANCNFSM6AAAAAASXO7S4Y . You are receiving this because you commented.Message ID: @.***>

iddm commented 1 year ago

But I, for instance, wasn't doing anything remotely at all. Everything was local - it was just a local folder and a local installation of everything on my PC. It isn't a problem which is only related to remote work (I understand this was where the discussion was going lately).

polidore commented 1 year ago

i just gave up on the old vim plugin. i was a bit nervous since i do most of my work in wsl, but vscode-neovim seems to be working for me so far.

lperson commented 1 year ago

I'm experimenting with the neovim extension. After installing neovim it seems to just work. It was NOT necessary to install neovim in my dev container, which is also great news. It seems to run locally. 🤞🏻 🎉

ianchanning commented 1 year ago

@huyz I switched to another editor (Helix), not because this is a temporary issue, but because it made me realize that modal editing is an afterthought in VS Code (despite this extension being awesome). And these issues will keep appearing without being a priority for VS Code.

But that's just me (modal editing is the most important part of my workflow). I'm sure downgrading is just fine for most people, as you mentioned.

Why don't you use the vscode-neovim plugin then? That should give you full modal editing inside VSCode.

ianchanning commented 1 year ago

Use the nvim extension. Seems this project isn't being maintained anymore.

@igniscyan This project clearly is being maintained - @J-Fields started looking into the issue 5 days ago.

aromeronavia commented 1 year ago

I know this is a very annoying issue, and I honestly tried Neovim VSCode, but I still came back to this because this project has been just good enough for me, and after I tried the temporal fix I'm quite happy, it's not perfect but it revives my previous workflow.

Let's try to be patient with the people maintaining this repository... obviously this is something completely non-intentional, and stuff happens... @J-Fields happy to contribute in any way possible, even just being a rubber duck or taking a look at specific parts of code

igniscyan commented 1 year ago

Use the nvim extension. Seems this project isn't being maintained anymore.

@igniscyan This project clearly is being maintained - @J-Fields started looking into the issue 5 days ago.

Didn't see. It's been marked as upstream so it's already looked into.

rtviii commented 1 year ago

Looking forward to the resolution.

ewsandor commented 1 year ago

I am seeing this issue as well.

VSCodeVim Version: v1.24.3

VSCode Version: Version: 1.75.1 Commit: 441438abd1ac652551dbe4d408dfcec8a499b8bf Date: 2023-02-08T21:35:30.018Z Electron: 19.1.9 Chromium: 102.0.5005.194 Node.js: 16.14.2 V8: 10.2.154.23-electron.0 OS: Linux x64 6.1.11-200.fc37.x86_64 Sandboxed: No

joehillen commented 1 year ago

@alecthomas Don't comment on GitHub issues with "Same" or "+1". It's rude, unhelpful, and spams everyone who is following the issue.

igniscyan commented 1 year ago

@alecthomas Don't comment on GitHub issues with "Same" or "+1". It's rude, unhelpful, and spams everyone who is following the issue.

This has been said upwards of 10 times on this thread. This is equally as useful as a +1 comment, pings everyone, and is intentionally contentious.

alecthomas commented 1 year ago

@joehillen In addition to what @igniscyan said, you also @ed the wrong person...

lperson commented 1 year ago

@alecthomas Don't comment on GitHub issues with "Same" or "+1". It's rude, unhelpful, and spams everyone who is following the issue.

This comment is not useful.

ddnomad commented 1 year ago

@alecthomas Don't comment on GitHub issues with "Same" or "+1". It's rude, unhelpful, and spams everyone who is following the issue.

Right, better let the issue disappear in the ether of obscurity, or get automatically closed as stale. Giving the maintainers a nudge that the issue affects a lot of people is clearly a step in a wrong direction 😛

ianchanning commented 1 year ago

sporadically maintained open source project

@lperson I've pointed this out to others - but this has been an amazingly well maintained project. It currently stands at 4,085 closed issues. That's phenomenal. I think it has reduced down to just one developer working on it.

So if this is sporadically maintained, all open source is sporadically maintained.

Either:

  1. Have patience
  2. Use the work-around
  3. Fork it
  4. Use something else

But don't go around insulting the project owners.

lperson commented 1 year ago

That's not an insult. It's a fact.

ianchanning commented 1 year ago

'sporadic' is an opinion

ianchanning commented 1 year ago

You will also note that @J-Fields is working on a fix - https://github.com/VSCodeVim/Vim/pull/8249

So everyone else be patient

t-var-s commented 1 year ago

I'm trying this workaround:

    {
      "commands" : [ "undo" ],
      "before" : [ "<leader>", "u" ]
    }

and although the issue comes and go it seems to be able to undo when u doesn't.

aromeronavia commented 1 year ago

@t-var-s can't find the comment that fixed this, but just try this:

  "vim.normalModeKeyBindingsNonRecursive": [
    {
      "before": ["u"],
      "commands": ["undo"]
    },
    {
      "before": ["c-r"],
      "commands": ["redo"]
    }
  ],
t-var-s commented 1 year ago

@aromeronavia For me, "before": ["u"] doesn't work with the undo command but something like "before" : [ "<leader>", "u" ] seems to be working.