344 comments

jeremyjh3 days ago
This story has no references that support the author's version of events, but it does appear to be substantially true that:

1. The change would break undo history, for both Neovim and Vim [see edit: this is not the really the case]

2. This means Neovim would delete data created by a different program, on another user's computer.

3. This was known before the feature was released.

4. They did it anyway.

I don't think there can really be any post-hoc justification of this.

https://github.com/neovim/neovim/pull/13973#issuecomment-789...

edit: I missed an important detail. The user specified the same path for undodir in both nvim and vim. Vim requires a path to enable the feature - there is no shared default path. The user sharing a path changes the story considerably in my view, because now this is a case of nvim deleting data created by nvim as an alternative to writing a data migration for it.

I could still disagree with that, but it makes alternatives like "just use a different path" more complicated at a minimum and really changes my read of this situation completely. I think Neovim's decisions are justfiable in this context. Maybe they could have saved the contents of the old undo folder somewhere and notified the user - arguably that would be more empathic I don't really agree they had a moral duty to do this.

soraminazuki3 days ago
The feature that was broken is called persistent undo. The docs unambiguously state that edit history will be preserved unless Vim/Neovim detects that the "undo file is no longer synchronized with the file it was written for."

https://neovim.io/doc/user/undo/#_5.-undo-persistence

So even putting aside the Vim/Neovim interoperability angle, that contract was broken. Undo files created by old versions of Neovim will be deleted by more recent versions.

The interoperability issue can't be ignored either. Neovim was touted as a drop-in Vim replacement, and that needs to be taken into account when considering how changes affect users.

So many Neovim users have started by reusing their existing vimrc. I'm sure many still have ~/.config/nvim/init.vim symlinked to ~/.vimrc to this very day. With Vim, persistent undo is opt-in. Vim users who cared enough to opt in are highly likely to have explicitly set the path for undo files too. That's because Vim defaults it to the same directory as the file being edited, which clutters the filesystem. As a result, there are many users who shares undo files between Vim and Neovim simply because they reused their vimrc, not because they made the conscious choice to do so.

dtech3 days ago
The data is stored in ~/.cache which has the contract that it user-wide cached data, which also means it can be deleted without severely impacting programs.

It seems the author has too high expectations of this feature, or vim is using an incorrect path to store this is they want to make it available more reliably

soraminazuki3 days ago
That's some weird technicality that has nothing to do with the issue while also being completely false.

https://github.com/neovim/neovim/blob/fc3f0041fbe01c96f38224...

The feature that was broken is called persistent undo. The feature was inherited from Vim. In case it's not obvious from the name, nowhere does it state in the docs for persistent undo that data may be deleted at any time.

https://neovim.io/doc/user/undo/#persistent-undo

That Neovim changed the default storage path for undo files is completely irrelevant to whether the contract for persistence should be broken.

MatthiasPortzel3 days ago
NeoVim docs say it defaults to "$XDG_STATE_HOME/nvim/undo//". Do you have a source for ~/.cache?

=> https://neovim.io/doc/user/options/#'undodir'

buu7003 days ago
This reads to me like a case of blame on both sides. Putting data you don't want to lose in ~/.cache is PEBKAC, but if that fact is incidental and NeoVim would have removed the undo history regardless of its filesystem path, then the point remains valid that NeoVim is deleting user data that isn't its place to delete.

A lot of the comments here are getting caught up in legal arguments which may or may not be valid. Those are irrelevant. No one is taking the NeoVim developers to court; the post is merely warning that they knowingly accepted behavior which can cause harm. The question is whether or not that choice was responsible, not whether it's legally actionable.

kelnos3 days ago
That's the wrong place to store it. Data like that should be under $XDG_STATE_HOME (~/.local/state/ by default).

I would consider deleting my persistent undo state, which would be something that I would have specifically enabled, to be "severely impacting".

Insanity3 days ago
I switched from Vim to NeoVim this year, after about 15 years on Vim.

Not withstanding this incident, I would say that on the whole it has been a good experience with Neovim. (I didn’t actually ever use the persistent undo functionality in vim. Guess because of VCS it’s less needed for my use-case).

schmichael3 days ago
Same timeline for me, but this was my 3rd or 4th attempt at switching. Not sure if something materially improved or maybe LLMs finally just got good enough at helping me convert.
throwaway8997733 days ago
> I think Neovim's decisions are justfiable in this context.

Needing to know in advance that neovim requires a specifying a different undodir to vim, because neovim's persistent undo format is unstable even though vim's is stable, but the feature is called the same thing and neovim bills itself as a plug and play replacement for vim...

This is very predictably going to lead to loss of user data.

johnnypangs3 days ago
But you still have to share the undodir for both vim and neovim right? If your undo data was that precious why would you gamble the interoperability? You could just have them in different folders and it would be fine.

So the case is, you really need you undo history and want to try out neovim so you just copy paste you vimrc to the new place and accidentally delete your data? I don’t think it’s that bad personally. It’s bound to happen but it’s not automatic.

johnnypangs3 days ago
I have a far less sensationalist headline for this which is:

Two programs that save their cache in the same folder causes issues.

gavinhoward3 days ago
As a Neovim user, this stopped me dead with painful realization: I may have suffered the same thing but didn't realize it. There was a time when I could not undo something, and it was after a Neovim upgrade.

Unlike Dr. Chisnall, I started my editor journey on Neovim, so it wasn't a transition that bit me. However, if the format of the persistent undo file is unstable, and Neovim just deletes it when it doesn't recognize the previous format, then it seems conceivable (to me) that an upgrade after changing the format would delete the file too.

Ouch. This is making me think about getting off of Neovim. Yes, FOSS comes as-is, but if there's an alternative...

cdmckay3 days ago
It’s such an odd design decision.

I could see ignoring the old undo data or warning before discarding it but just silently wiping it is so user hostile it’s hard to comprehend.

rcxdude3 days ago
It feels like a mismatch in expectations. It's fairly obvious the developers consider the persistent undo feature to be a convenience for short-term continuity if you are exiting and re-entering the editor over a single edit session, not a long-term storage of the history of the file. All of their decisions make perfect sense in that context, but it seems that expectation is not shared by some of their users, who considered it to be an important piece of data meant to be kept long-term. This feels a bit odd to me, given the tendency for undo systems to be fragile anyway, and the documented fragility of this persistence. The author of this article even had deliberate workarounds for some of this fragility which I feel would put me in 'should I even trust this feature?' mode. To me the main fix would be updating the documentation to scream even more loudly "Don't expect this to stay around!".

To me it's a bit like storing your important files in a ramfs and then complaining that your OS doesn't respect user data when it crashes. Sure, it's not exactly a documented behaviour of the system, but you're also not storing your data in a place the developers of the OS expected you to put important data.

59percentmore3 days ago
It's some sort of industry standard, though, isn't it? Google Chrome on Android auto-deletes the history database silently if it deems it corrupted (e.g., due to a bad write on a system with low storage). You just open your browser one day and it's all gone.

If not, I wonder how Google justifies it.

loeg3 days ago
If you ignore it, do you continue allowing edits to the file? Now undo history is corrupt and useless anyway. Or do you disallow editing until the user manually deletes some hidden, implementation-detail file for a feature they probably never use?
antonkochubey3 days ago
Sorry for my ignorance, but what is the usefulness of undo persistence after a IDE restart? Don't you normally save your changes and finish a piece of work before exiting an DE?

Edit: some great examples in the replies here, thanks! Perhaps I should start using it in editors that support it, never gave it a thought before.

schmichael3 days ago
The reason why this feature is particularly useful in vi-likes is because they are not IDEs. I hop in and out of vi all day long. Depending on the task I might create a new tab, run a command in vi, or exit vi to run it. Vi’s appeal is that it is “just” an editor and your terminal and workstation form your un-integrated development environment.
jeremyjh3 days ago
The whole point of undo is that you realize you made a mistake later. If you've done that after you've saved your changes and exited the program, you'd have no expectation of undo still working unless you've enabled this feature.

It doesn't matter whether or not you can think of a reason you would want to enable it, but it should be pretty trivial to do so. Once you've enabled it, it should work.

drfloyd513 days ago
The article gave 2 examples.

I can give some as well. IDE crashes. Computer reboots at an undesired time. Even if my work is saved, I am not “finished”. I would like my undo history to extend before file / open time.

traverseda3 days ago
I often use it to edit system config files, often on embedded devices where I don't have my git credentials setup, or on servers. In these cases we're already not in an ideal world, I don't have good reliable version control or change management in place. In those less-than-ideal worlds, having proper undo history is nice.
kelnos3 days ago
One silly example: sometimes I'll open up source or config file to make a quick, temporary change in order to test something. But then instead of ctrl+z backgrounding it, I'll accidentally quit vim. Then I start it back up to undo the change, and find that there's no undo history.

I didn't know about persistent undo until seeing this posted here on HN, but now I've enabled it! Of course, turns out it's an unreliable feature on nvim... maybe I'll consider switching back to the original (for that and other reasons).

sdcfgy3 days ago
I've used vim since the first time it appeared in Debian repos. I have been told a thousand times that NeoVim is better, more modern and solves many (conveniently never cited) issues. I just ignored it and carried on. Feeling terribly vindicated at this point as it's a feature I use regularly and have no idea that it would be an issue in NeoVim.
kps3 days ago
I've used vi and nvi and (now) vim, and tried neovim, but :! is broken and “Conform to POSIX vi” is one of their “Non-goals”.
0cf8612b2e1e3 days ago
POSIX vi is so barebones that nobody* wants that.

Bare vi does not have windows, visual selection mode, multiple level undo, color schemes, etc.

NVim wants to improve some defaults, which cannot be done if it is beholden to all legacy code. That being said, I still think this specific undo example is insane.

sodapopcan3 days ago
Nvim's `:!` behaviour was a deliberate design decision, which is one of the reasons I just stick with Vim9.
mahboi3 days ago
I've never used NeoVim because Vim has been good enough.
tombert3 days ago
Vim is good enough now. The reason I switched to NeoVim in like 2015 is because it had async plugin support. With vanilla Vim at the time, if you had a lot of plugins it could get pretty slow and stuttery pretty quickly.

Vanilla Vim added it in 2016 I think, but by that time I had already fully switched to NeoVim and it didn't seem worth it to me to switch.

debo_3 days ago
*vimdicated
WesolyKubeczek3 days ago
I used neovim because it felt way faster by default. I think treesitter runs circles around what classic vim is using to highlight syntax. That said, I never used both beyond basics, thus no horror stories either.
sdcfgy3 days ago
I haven't noticed any performance issues in vim to start with. It was fast on a 75MHz pentium for me. The syntax highlighting, same. No issues. I don't always use that though because I can't be bothered to set up anything much past the basic config.
sodapopcan3 days ago
Tree-sitter is more performant for sure, and its potential for easier text objects is nice. However, Vim's syntax engine is more than good enough for non-complex highlighting (and many people don't want complex highlighting) and, while I don't have enough tree-sitter knowledge to explain this myself, I've seen examples of Lua versions of Vim plugins where tree-sitter is unable to handle some of the regex-based text objects present in the vimscript version.

As far as really cool uses for tree-sitter go, ast-grep is a fantastic tool. Of course it's a standalone program, so it doesn't need nvim to make use of it.

gchamonlive3 days ago
Am I missing something? Are people using persistent undo as backup?

This seems however more like of a documentation and UX problem. Neovim should warn and ask before deleting old undo files, or at least back them up, but it's not neovim's fault if people don't use reliable backup and versioning systems. Relying on persistent undo for this is kind of a self inflicted wound.

Use the proper tools for the job. Saying that neovim developers "had no concept of a duty of care to their users" is really disrespectful. Neovim's Lua API is overflowing with care, you just need to go look.

sdorf3 days ago
I've always assumed that undo history is ephemeral in any application I use, other than maybe an application where history is first-class in a timeline like Fusion360. I'm surprised to hear that people rely on it being persistent.
gchamonlive3 days ago
Persistent undo is useful, but when it's unavailable or corrupted for me it's like "oh too bad", because it's just a convenience. And then I read things like this I get horrified by the workflows people adapt in order to avoid learning how to use the available tools properly. Seriously, it's just vim, borg and git...
delecti3 days ago
> I'm surprised to hear that people rely on it being persistent.

The feature's name has "persistent" in it.

drfloyd513 days ago
Not using it as a backup strategy. But it doesn’t matter. Vim has a feature, persistent undo. People are using it for whatever reason. Under your blessing or not. A different app, neovim, broke vim’s feature.

They don't get a pass because you disagree with an imagined use case.

gchamonlive3 days ago
Yeah, they could have done better, but to say they "had no concept of a duty of care to their users"... Isn't it a bit much?
whatevaa3 days ago
https://xkcd.com/1172/

Seems so. As smart as keeping tabs open in browser instead of using bookmarks, but "workflow".

gchamonlive3 days ago
Btw zen browser's folders are many streets ahead of Firefox's traditional bookmarking.
BarbaryCoast3 days ago
According to the rev history for VIM, persistent undo arrived in version 7.3, released in 2010. So Chisnall may have used it since 2000, but he didn't have persistent undo for at least two of the books he wrote. And it means it wasn't "maintained for almost 20 years", it's at best 16.

But it is a nice feature.

I do that by using version control. I have it hooked to my editor so that "save" is "check in". Now I have persistent, versioned, copies of all my states independent of whatever tools I happen to be using.

loeg3 days ago
Keep in mind NeoVim forked in 2014, too.
drfloyd513 days ago
Type A. Type B. Save. Type C. Save. How do you get back to state “A” using git?

You do not have all your states available.

yonatan80703 days ago
Maybe through autosave? If your editor makes a commit every time you're inactive for longer than X seconds that should solve that, which I'm pretty sure is how most editor undo stacks work at some level.

I just tried it in Nextcloud Notes on Android (FlorisBoard has undo/redo buttons), and it seems to work this way. If I type a bunch of words quickly and hit undo, it removes all of them. If I stop for a couple seconds between each word, it undos them one-by-one.

queenkjuul3 days ago
Is 16+ not almost 20?

Read the full thread on Hacker News →

Related stories