Vim: Undo broken with new VS Code
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.
- i → insert mode
- a → “a”
- b → “ab”
- ESC → normal mode
- u → “a”
- u → nothing happens, but should’ve undone “a”
- CTRL-Z → “ab” (undoes what u just undid)
- CTRL-Z → “a”
- CTRL-Z → “”
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
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 283
- Comments: 159 (6 by maintainers)
Commits related to this issue
- chore: Fix VSCodeVim/Vim/issues/8157 — committed to gladevise/dotfiles by gladevise a year ago
- Vscode: add workaround for vim extension bug See https://github.com/VSCodeVim/Vim/issues/8157#issuecomment-1426704638. — committed to AlphaHydrae/env by AlphaHydrae a year ago
- Attempt to fix undo. Refs #8157. The issue is pretty clearly that a recent VS Code update caused `onDidChangeTextDocument` events to be created (unreliably, from my testing) in such a way that trips ... — committed to VSCodeVim/Vim by J-Fields a year ago
Apologies for my slowness in responding to this issue; I’ve been quite busy with other things recently.
This should be fixed in
v1.25.1
. If you’re still experiencing this issue, please leave a comment letting me know. If there’s some other misbehavior related to undo, please file a new ticket.When mapping the
u
to vscode’sUndo
and<Ctrl-r>
to vscode’sRedo
insettings.json
it works for me again.Still broken then… to summarize
Solution 1.
Solution 2.
Solution 3.
Solution 4.
Until this issue is resolved, VSCode undo, redo can be temporarily set to Vim key bindings.
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 😛
@igniscyan This project clearly is being maintained - @J-Fields started looking into the issue 5 days ago.
Undo after saving the file or even before saving it doesn’t work for me as it used to do before the bug. VS Code 1.74.2
https://user-images.githubusercontent.com/55108505/210176104-2439956b-8a36-4d2e-9baa-faa31de313cb.mp4
@J-Fields thank you for letting me unsubscribe from this embarrassing whine-fest 😜
@alecthomas Don’t comment on GitHub issues with “Same” or “+1”. It’s rude, unhelpful, and spams everyone who is following the issue.
i think we have discovered the hardest engineering problem known to man
Please stop with the annoying
+1
and “same issue” posts. Just thumb up the OP so that we can stay subscribed to this thread without reading dumb me-too posts@t-var-s can’t find the comment that fixed this, but just try this:
Thanks @J-Fields, I really appreciate the effort that you’ve put into this extension, it’s amazing.
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.
Use the nvim extension. Seems this project isn’t being maintained anymore.
This is killing me.
Not trying to stir any hostilities here, but having some sort of an acknowlegment from maintainers that they are aware this is an issue and are working (at their own pace!) towards resolving it would probably help to put people at ease and reduce amount of “me too” here.
Same here.
I give up. I uninstalled the vim extension.
Still broken for me in version 1.26.0
You will also note that @J-Fields is working on a fix - https://github.com/VSCodeVim/Vim/pull/8249
So everyone else be patient
This comment is not useful.
When I press u, vscode undo to the latest change, and if press u again nothing happend.
saaame
Same here
@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:
But don’t go around insulting the project owners.
That’s not an insult. It’s a fact.
+1
Same issue here, latest update broke things again
‘sporadic’ is an opinion
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
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
@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.
https://github.com/VSCodeVim/Vim/issues/8157#issuecomment-1426704638
That works, but the native undo only undoes one time of the macro. Example:
+1, unusable VSCodeVim.
+1 also keeps the issue alive - emojis do not IIRC
same here vscodevim: v1.24.3 Visual Studio Code: 1.75.0 OS: MacOS 13.2 (22D49)
I am using VS Code
1.75.0
and still encounter this problem. I downgraded the VsCodeVim version to1.1.0
to fix it for now.so is this gonna be addressed?
The issues #8200 and #8201 seem to have appeared at the same time as this one. Is someone else affected by them? Has someone been able to reproduce the issue starting from a clean VS Code configuration? I’m trying, but with no success so far.
@J-Fields I’m still having the issue. This is my
settings.json
:Thank you for the fix 👍
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.
So simplifying my earlier bug report:
yy
p
u
- this doesn’t work.Here is the debug log for this:
If I close and restart VSCode it does briefly work (I don’t know at what point it stops):
Here’s the diff (Vim still does diffs better than VSCode 😉):
Two critical logs that appear in the working version but not in the failing version:
Not sure about this rest…
For any people interested in switching to VSCode Neovim, it seems to be fairly painless.
I have tested out the extension and it is pretty nice. Has more moving parts, a bit weird and requires some getting used to, but overall it does the job and comes with more flexibility in terms of doing things within
init.lua
orinit.nvim
.It does require having
neovim
installed on your host, but I rely on it a lot anyways, so that is not a big issue for me.As always, your experience may vary.
Changes necessary to make it work: https://github.com/ddnomad/dotfiles/commit/d060fb7d3d66c682e729695a954ea0bb3f956593
@ddnomad I am only on MacOS and still have the issue since the update
We need one of the maintainer’s eyes on the PR for it to have any effect, any sort of acknowledgement would be good here.
Seeing mixed messages here of it working and not working. It’s intermittent - sometimes it works, sometimes it doesn’t. It’s almost something is happening upon save that is sometimes erasing history. Seems to be completely random - I’ve typed and re-typed the same text over and over again, and it is about 50/50 chance of remembering history after a save.
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.
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
-pressesEg. call trace
I am running vscode 1.75.1, haven’t tried comparing with an older vscode version
Thank you for the reproducing example, @ianchanning. I am able to cause this bug consistently with your method using vscode
1.75.1
and vim-extensionv1.24.3
.However, I’m not able to reproduce this with OSS vscode built from source on tag
1.75.1
and only installing vscode-vimv1.24.3
via vsix. No problem undoing whatsoever.I switched to use the VSCode NeoVim plugin. Pretty straightforward. Also, happy to pair program with literally anyone in this forum to see if we can find the root cause for this, I’d love to jump back to this project, the plugin is really unusable without this
EDIT: This comment solved it all https://github.com/VSCodeVim/Vim/issues/8157#issuecomment-1426704638 I’m now back to this plugin
I’ve found the debug statements now. You need to open up the literal Electron/Chrome Developer Tools within VSCode via
Help > Toggle Developer Tools
It’s the
HistoryTracker
logs we’re interested in.+1 this is insanely annoying
same issue. Quite strange since I’ve been using the same version for some time now
Strangely I just started experiencing this today, though presumably I have been on 1.75.0 since it released. Downgrading to 1.72.2 as someone above recommended seems to fix it.
same here and the
.
repeat function is also broken@marchbox are you able to undo changes with “u” after saving a file? I can still reproduce that issue with 1.74.2. which may be related to this. The last version where that worked for me is 1.72.2, see #8188.
I have already done everything you suggested except for first upgrading to the latest vscode and then checking, perhaps, this is the reason I couldn’t see the new version. 😃
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
Didn’t see. It’s been marked as upstream so it’s already looked into.
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. 🤞🏻 🎉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.
Having this issue as well
I do look forward to finding time to switch to VSCodium (especially in light of https://github.com/iocave/customize-ui/issues/156) and using OpenVSX as an extensions marketplace. Given that OniVim uses the same marketplace and VSCodium has VSCode Neovim, I tend to be rather sceptical of OniVim’s future, especially as it uses a rather exotic framework for its UI (Revery).
Only time will tell.
I tried downgrading the extension to 1.22.0 using VS Code 1.75.0 Darwin arm64 21.6.0 and am still running into the problem. Definitely seems like something changed on the VS Code side.
@ianchanning
I did, but I was looking at the wrong thing, I was focused (no pun intended) on the “Command” column, which has nothing to hint at the job of
J
in VIM, and didn’t see the “Source” column.Same here 😦
@edit: Posting “+1” or “Same here” should not be interpreted as unnecessary flooding. It should be, instead, interpreted as a nice way to show to the maintainers that the issue is affecting a large user-base. That’s my goal 😃
We’re all software engineers. Can we put up a PR to fix this rather than piling on with complaints?
I haven’t had time to dig into the code but I found a PR that touched registers from late last year. It shipped in 1.24.3. That’s probably where I’d start looking.
Same issue (intermittently). I noticed it yesterday for the first time. I updated to macOS Ventura 13.1 (from Monterey) on Saturday.
Version: 1.75.0 (Universal) Commit: e2816fe719a4026ffa1ee0189dc89bdfdbafb164 Date: 2023-02-01T15:24:42.903Z (4 days ago) Electron: 19.1.9 Chromium: 102.0.5005.194 Node.js: 16.14.2 V8: 10.2.154.23-electron.0 OS: Darwin x64 22.2.0 Sandboxed: Yes
Downgrading to 1.73.1 fix the bug.
Same for me with VSCode Version 1.74.2 I cannot undo any change done in normal mode without having to use C-z. VscodeVim undo states ‘Already at oldest change’ even without saving inbetween.
I’m a bit confused…
iab<Esc>u
should undo the entire insertion (“ab”, not just “a”), which is what I’m seeing, at least on VS Code 1.74.2.If anyone is still experiencing this, please post settings.
Same here.
this. same here
Same here
I’m having this same problem … I’m using VS Code 1.74.0-insider. I’m using Ubuntu, so I don’t think this is OS related.