‹ BackHN Continuity

Thread

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

384 points · 346 comments · jandeboevrie

  1. RVuRnvbM2e · · focus · HN ↗
    Undo files and persistent undo are not meant to work that way. They are just persistent across process restarts. That's all.

    They live in ~/.cache which is defined as "user-specific non-essential (cached) data".

    Despite this user's impressive résumé, they simply misunderstood the feature.

    1. kazinator · · focus · HN ↗
      In what way is it not a process restart if I stop the process, install/upgrade NeoVim and start a new process?
      1. tremon · · focus · HN ↗
        The lifetime of files in ~/.cache/ is the same as what the FHS documents for /var/cache [0]:

        > Application cache data. Such data are locally generated as a result of time-consuming I/O or calculation. The application must be able to regenerate or restore the data. The cached files can be deleted without loss of data.

        Meaning: the persistence of such files is not guaranteed across application restarts. If vim (and also neovim) had intended for the undo files to outlive the program, the files should have been put in ~/.local/state instead -- as also explicitly documented by the XDG [1]:

        > [XDG_STATE_HOME] may contain: [..] current state of the application that can be reused on a restart (view, layout, open files, undo history, …)

        [0] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Filesystem_Hierarchy_Standard#mwATw" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Filesystem_Hierarchy_Standard#...

        [1] <a href="https:&#x2F;&#x2F;specifications.freedesktop.org&#x2F;basedir&#x2F;latest&#x2F;#variables" rel="nofollow">https:&#x2F;&#x2F;specifications.freedesktop.org&#x2F;basedir&#x2F;latest&#x2F;#varia...

        1. maxnoe · · focus · HN ↗
          &gt; The application must be able to restore or regenerate the data

          That&#x27;s a break of the contract then, right? The application was not able to regenerate or restore.

          Cache is the wrong place for a persistent undo file.

          1. [deleted] · · focus · HN ↗

            [deleted]

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.