Swap file recovery fails, when the only change was adding a one character line

14 views
Skip to first unread message

s.spa...@web.de

unread,
Jan 18, 2021, 1:25:56 PM1/18/21
to vim...@googlegroups.com
Hi vim team,

thank you for developing vim.
I discovered the following strange behaviour; seems to be a bug:

Swap file recovery fails, when the only change was adding a one character line.

Steps to reproduce:

First create a text file OPT.txt to play with (I take a copy of a help page)
vim -u NONE
:help options
:w OPT.txt
:q

Edit OPT.txt and add a new line just containing x after line 5000
vim -u NONE OPT.txt
:5000
ox<Esc>

Wait some seconds for the swap file to be written out.
Then without having saved, on another terminal kill vim
kill -9 <PID>

Recover and save the result as new file
vim -u NONE -r OPT.txt
:w OPT_recovered.txt
:q!

Diff to see what we got
diff -s OPT.txt OPT_recovered.txt

What I would expect as output from the diff:

5000a5001
> x

What I get instead:

5040a5041
> Lisp mode: When <Enter> is typed in insert mode set the indent for

I. e. 40 lines further down any line got duplicated; that is something
completely different than what I did (adding the line with the x).

I can reproduce this with any play file; you can also create a play file by
starting with an empty file and then
10000ohello<Esc>

When instead I add two x instead of one
oxx<Esc>

then everything works fine, and I get as output from the diff

5000a5001
> xx

Could you please have a look at it?

System information:
- Debian 10
- Package vim-gtk/stable,stable,now 2:8.1.0875-5 amd64
- Output from :version is:
VIM - Vi IMproved 8.1 (2018 May 18 kompiliert am Jun 15 2019 16:41:15)
Inklusive der Patches: 1-875, 878, 884, 948, 1046, 1365-1368, 1382, 1401
Verändert von team...@tracker.debian.org
Übersetzt von team...@tracker.debian.org
Riesige Version mit GTK2 GUI.
- I did my tests in an xterm, without the GUI.

Thank you and have a good time!

Paul

Bram Moolenaar

unread,
Jan 18, 2021, 4:30:28 PM1/18/21
to vim...@googlegroups.com, s.spa...@web.de
I cannot reproduce it. This may very well depend on the exact content
of the file and position of line breaks.

Vim 8.1 is quite old, please try with a newer version.

--
If Microsoft would build a car...
... You'd have to press the "Start" button to turn the engine off.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

s.spa...@web.de

unread,
Jan 19, 2021, 3:53:58 AM1/19/21
to vim...@vim.org

s.spa...@web.de

unread,
Jan 19, 2021, 3:53:58 AM1/19/21
to vim...@vim.org
Reply all
Reply to author
Forward
0 new messages