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

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

关于用户数据保护:NeoVim 导致 Vim 撤销文件被删除

A Mastodon post by computer scientist David Chisnall has a very Unsung opener: I have used vim since around 2000. I have written five books, a PhD thesis, a few dozen papers and over 150 articles with it. At this point, my higher brain functions are not engaged at all when I use a bunch of common vim commands, they just happen. Documents I wrote with anything else have random :w in the middle.

计算机科学家 David Chisnall 在 Mastodon 上发布的一篇文章有着非常“Unsung”风格的开场白:“我从 2000 年左右就开始使用 Vim。我用它写了五本书、一篇博士论文、几十篇论文和 150 多篇文章。到了现在,当我使用那些常用的 Vim 命令时,我的大脑高级功能根本不需要参与,一切都是肌肉记忆。我用其他软件写的文档里,中间总会莫名其妙地出现 :w。”

Chisnall goes on to talk about one specific vim feature: Persistent undo is one of my favourite features of vim. […] I don’t often need the persistent undo. But on the few occasions when I have needed it, it’s been invaluable: ooops, I deleted something from this file, maybe last week and one reboot ago, what was it? Undo until I find it, copy it, paste it into the current version. Or, a bit more commonly: I had this working, then I tidied it up ready to commit, now it isn’t working, what did I do? Vim has kept this working across major version upgrades over a period of about 20 years. I don’t even think about it, it’s just part of Raskin’s First Law: A program may not harm a user’s data or, through inaction, allow a user’s data to come to harm. If vim or the computer crash, or if I close a file and come back to it six months later, my undo history is still there.

Chisnall 接着谈到了 Vim 的一个特定功能:“持久化撤销(Persistent undo)是我最喜欢的 Vim 功能之一。[……] 我并不经常需要它,但在我确实需要的那几次,它简直无价:‘哎呀,我从这个文件里删了点东西,可能是上周或者重启前删的,那是什么?’ 撤销直到找到它,复制,然后粘贴到当前版本。或者更常见的情况:‘我刚才把它调通了,然后整理了一下准备提交,现在却跑不通了,我到底改了什么?’ Vim 在过去 20 年的大版本升级中一直保持着这个功能。我甚至不需要去想它,它就是拉斯金第一定律(Raskin’s First Law)的一部分:程序不得损害用户的数据,或因不作为而允许用户的数据受到损害。如果 Vim 或电脑崩溃,或者我关闭文件六个月后再打开,我的撤销历史依然在那里。”

NeoVim is a fork of vim (in news for other reasons): So I tried NeoVim when it was quite new. Vim that you are familiar with, but better? Great! The first thing I noticed in NeoVim was that undo didn’t work. I tried opening the file in vim and undo didn’t work there either. Neovim had changed the format of the undo files. It hadn’t upgraded the old one. It hadn’t used a different name for its undo files. It had just noticed the existence of a vim undo file, deleted it (losing all of the data in it) and replaced it with one that vim couldn’t read.

NeoVim 是 Vim 的一个分支(因其他原因而上过新闻):“所以当 NeoVim 刚出来时,我试用了它。你熟悉的 Vim,但变得更好了?太棒了!我在 NeoVim 中注意到的第一件事就是撤销功能失效了。我试着在 Vim 中打开文件,发现撤销功能也失效了。NeoVim 更改了撤销文件的格式。它没有升级旧文件,也没有为撤销文件使用不同的名称。它只是检测到了 Vim 撤销文件的存在,直接将其删除(导致其中的所有数据丢失),并替换为一个 Vim 无法读取的新文件。”

I raised an issue about this and was told that the persistent undo format was unstable and users should not rely on data being preserved in a feature explicitly called persistent undo. It had changed once and would probably change again. And that ended my experience with NeoVim. The authors showed immediately that they absolutely could not be trusted with any of my data. Breaking persistent undo is something I could forgive as a bug, but the attitude that just because something is a persistent file on your filesystem that contains data that you might want is no reason for their program not to delete it meant they had no concept of a duty of care to their users.

“我为此提交了一个 Issue,结果被告知持久化撤销格式是不稳定的,用户不应该依赖一个明确命名为‘持久化撤销’的功能来保存数据。它已经改变过一次,而且很可能会再次改变。那次经历结束了我对 NeoVim 的使用。开发者们立刻表现出他们绝对不值得托付我的任何数据。破坏持久化撤销功能我可以将其视为一个 Bug 而原谅,但那种认为‘仅仅因为它是你文件系统里的一个持久化文件,且包含你可能需要的数据,并不代表我们的程序就不能删除它’的态度,意味着他们根本没有对用户尽责的概念。”

I liked this post (which I quoted almost in its entirety), because it covers a few important things: I have never heard of the persistent undo like that, and it seems kind of amazing. People do remember when software loses their hard work or disrespects them. I can see how “It had changed once and would probably change again” can be such a powerful feeling. I also loved it for the appearance of Raskin’s First Law.

我很喜欢这篇文章(我几乎全文引用了它),因为它涵盖了几个重要的点:我以前从未听说过这种持久化撤销功能,它看起来非常神奇。人们确实会记住软件何时丢失了他们的心血或表现出对他们的不尊重。我能理解“它已经改变过一次,而且很可能会再次改变”这种说法为何如此令人心寒。我也很喜欢文中提到的拉斯金第一定律。

Jef Raskin, of Macintosh and Canon Cat fame, put together the three laws in his 2000 book The Humane Interface, and they go as follows: A computer shall not harm your work or, through inaction, allow your work to come to harm. A computer shall not waste your time or require you to do more work than is strictly necessary. An interface is humane if it is responsive to human needs and considerate of human frailties. It was a very important and formative book for me to encounter as a young designer. I have no idea how these laws haven’t made it to Unsung before today.

因 Macintosh 和 Canon Cat 而闻名的 Jef Raskin 在他 2000 年的著作《人机界面》(The Humane Interface)中提出了这三条定律,内容如下:计算机不得损害你的工作,或因不作为而允许你的工作受到损害。计算机不得浪费你的时间,或要求你做超出必要的工作。如果一个界面能够响应人类的需求并考虑到人类的弱点,那么它就是人性化的。作为一名年轻的设计师,读到这本书对我来说非常重要,也塑造了我的职业观。我真不知道为什么这些定律直到今天才出现在 Unsung 上。