‹ BackHN Continuity

Thread

On caring for user data: NeoVim caused Vim undo files to be deleted

384 points · 346 comments · jandeboevrie

  1. jeremyjh · · focus · HN ↗
    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.

    <a href="https:&#x2F;&#x2F;github.com&#x2F;neovim&#x2F;neovim&#x2F;pull&#x2F;13973#issuecomment-789262094" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;neovim&#x2F;neovim&#x2F;pull&#x2F;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 &quot;just use a different path&quot; more complicated at a minimum and really changes my read of this situation completely. I think Neovim&#x27;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&#x27;t really agree they had a moral duty to do this.

    1. dtech · · focus · HN ↗
      The data is stored in ~&#x2F;.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

      1. [deleted] · · focus · HN ↗

        [deleted]

      2. wonnage · · focus · HN ↗
        So if a program decided it owned .cache and deleted it every startup you’d be fine with it?
        1. dtech · · focus · HN ↗
          What a weird straw-man. The comparison here is a program breaking compatibility with a file in ~&#x2F;.cache&#x2F;... and deleting it instead of providing compatibility. I&#x27;d do that without thinking about it twice.
          1. freehorse · · focus · HN ↗
            I don&#x27;t see it as a strawman. The comparison here is a program breaking compatibility with a file _used by another program_. If vim and neovim undo files are incompatible, why does neovim delete vim&#x27;s file instead of using its own file name&#x2F;extension and not caring about vim&#x27;s undo? And why do they use the same subdirectory even? To me it is a case of a program deleting cached files of another program, which, as a user, I see as deleting user data that said program should have touched.
        2. yjftsjthsd-h · · focus · HN ↗
          Honestly, kinda? It&#x27;d be rude and cause a performance regression, but it shouldn&#x27;t break anything.
      3. [deleted] · · focus · HN ↗

        [deleted]

      4. buu700 · · focus · HN ↗
        This reads to me like a case of blame on both sides. Putting data you don&#x27;t want to lose in ~&#x2F;.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&#x27;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&#x27;s legally actionable.

      5. MatthiasPortzel · · focus · HN ↗
        NeoVim docs say it defaults to &quot;$XDG_STATE_HOME&#x2F;nvim&#x2F;undo&#x2F;&#x2F;&quot;. Do you have a source for ~&#x2F;.cache?

        =&gt; <a href="https:&#x2F;&#x2F;neovim.io&#x2F;doc&#x2F;user&#x2F;options&#x2F;#&#x27;undodir&#x27;" rel="nofollow">https:&#x2F;&#x2F;neovim.io&#x2F;doc&#x2F;user&#x2F;options&#x2F;#&#x27;undodir&#x27;

      6. soraminazuki · · focus · HN ↗
        That&#x27;s some weird technicality that has nothing to do with the issue while also being completely false.

        <a href="https:&#x2F;&#x2F;github.com&#x2F;neovim&#x2F;neovim&#x2F;blob&#x2F;fc3f0041fbe01c96f38224d65d27664b22b5ef78&#x2F;runtime&#x2F;doc&#x2F;options.txt#L7146" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;neovim&#x2F;neovim&#x2F;blob&#x2F;fc3f0041fbe01c96f38224...

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

        <a href="https:&#x2F;&#x2F;neovim.io&#x2F;doc&#x2F;user&#x2F;undo&#x2F;#persistent-undo" rel="nofollow">https:&#x2F;&#x2F;neovim.io&#x2F;doc&#x2F;user&#x2F;undo&#x2F;#persistent-undo

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

      7. kelnos · · focus · HN ↗
        That&#x27;s the wrong place to store it. Data like that should be under $XDG_STATE_HOME (~&#x2F;.local&#x2F;state&#x2F; by default).

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

        1. em-bee · · focus · HN ↗
          it&#x27;s not the default place, it&#x27;s where the user decided to put it.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.