E315: ml_get errors when recovering from a swap file

已查看 18 次
跳至第一个未读帖子

Yegappan Lakshmanan

未读,
2021年6月7日 16:00:342021/6/7
收件人 vim_dev
Hi,

When developing tests for the memline.c file, I ran into a E315
ml_get error when trying to recover from a swap file on a Linux
system using the following function:

func Test()
call delete('Xfile1')
call delete('Xfile2')
call delete('.Xfile1.swp')
call writefile([], 'Xfile1')
silent !ln -s Xfile1 Xfile2
edit Xfile2
preserve
let b = readblob('.Xfile1.swp')
%bw!
call writefile(['aaa', 'bbb', 'ccc'], 'Xfile1')
call writefile(b, '.Xfile1.swp')
recover Xfile1
endfunc
call Test()

After calling this function, press Enter for the prompts, you will
see a series of E315 errors.

- Yegappan

Bram Moolenaar

未读,
2021年6月8日 12:18:532021/6/8
收件人 vim...@googlegroups.com、Yegappan Lakshmanan
I ran this in the src/testdir directory with "vim --clean". I got:

"Xfile2" 0L, 0B
File preserved
2 buffers wiped out
Using swap file ".Xfile1.swp"
Original file "~/vim/vim82/src/testdir/Xfile1"
Recovery completed. You should check if everything is OK.
(You might want to write out this file under another name
and run diff with the original file to check for changes)
You may want to delete the .swp file now.
Note: process STILL RUNNING: 868546


No ml_get errors. Something else needed?

--
The problem with political jokes is that they get elected.

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

Dominique Pellé

未读,
2021年6月8日 13:43:052021/6/8
收件人 vim_dev
Same here, I could not reproduce the ml_get_errrors with vim-8.2.2960.

Regards
Dominique

Yegappan Lakshmanan

未读,
2021年6月8日 17:33:522021/6/8
收件人 Bram Moolenaar、vim_dev
Hi Bram,
Looks like the viminfo file needs some entries pointing to Xfile1
to reproduce this issue. The following commands reproduce the issue:

<place the above Test() function in a file called test.vim>

vim --clean -c 'set viminfofile=' -c 'call writefile(["aaa", "bbb",
"ccc"], "Xfile1")' -c 'edit Xfile1' -c 'normal 3Gyy' -c 'call
delete("Xfile1")' -c 'q'
vim --clean -c 'set viminfofile=' -c 'source test.vim' -c 'call Test()'

- Yegappan

Bram Moolenaar

未读,
2021年6月9日 06:34:212021/6/9
收件人 vim...@googlegroups.com、Yegappan Lakshmanan
OK, I can reproduce it now. It's because the cursor is positioned
further down in the file and then recovering deletes lines.

It's easy to fix, but reproducing the problem is complicated. It should
be possible to simplify though, knowing how it happens (when reading the
file an autocommand moves the cursor to the last used position).

--
"I've been teaching myself to play the piano for about 5 years and now write
most of my songs on it, mainly because I can never find any paper."
Jeff Lynne, ELO's greatest hits

Yegappan Lakshmanan

未读,
2021年6月9日 23:26:392021/6/9
收件人 Bram Moolenaar、vim_dev
Hi Bram,

On Wed, Jun 9, 2021 at 3:34 AM Bram Moolenaar <Br...@moolenaar.net> wrote:
>
> OK, I can reproduce it now. It's because the cursor is positioned
> further down in the file and then recovering deletes lines.
>
> It's easy to fix, but reproducing the problem is complicated. It should
> be possible to simplify though, knowing how it happens (when reading the
> file an autocommand moves the cursor to the last used position).
>

Thanks for the hint. I have added a test for this bug and
created a PR.

- Yegappan
回复全部
回复作者
转发
0 个新帖子