From 670a577c6b7b6f950c738261937c2b6d55a7faec Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 6 Oct 2020 23:14:41 -0400 Subject: vim-patch:8.2.1599: missing line end when skipping a long line with :cgetfile Problem: Missing line end when skipping a long line with :cgetfile. Solution: Fix off-by-one error. (closes vim/vim#6870) https://github.com/vim/vim/commit/59941cbd8035415d68683edc4e571306b10669ad --- src/nvim/quickfix.c | 2 +- src/nvim/testdir/test_quickfix.vim | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 7d4f52af34..1fe301b0d9 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -808,7 +808,7 @@ retry: } break; } - if (STRLEN(IObuff) < IOSIZE - 1 || IObuff[IOSIZE - 1] == '\n') { + if (STRLEN(IObuff) < IOSIZE - 1 || IObuff[IOSIZE - 2] == '\n') { break; } } diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 42ca0fe1d3..520007a993 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -1597,6 +1597,24 @@ func Test_long_lines() call s:long_lines_tests('l') endfunc +func Test_cgetfile_on_long_lines() + " Problematic values if the line is longer than 4096 bytes. Then 1024 bytes + " are read at a time. + for len in [4078, 4079, 4080, 5102, 5103, 5104, 6126, 6127, 6128, 7150, 7151, 7152] + let lines = [ + \ '/tmp/file1:1:1:aaa', + \ '/tmp/file2:1:1:%s', + \ '/tmp/file3:1:1:bbb', + \ '/tmp/file4:1:1:ccc', + \ ] + let lines[1] = substitute(lines[1], '%s', repeat('x', len), '') + call writefile(lines, 'Xcqetfile.txt') + cgetfile Xcqetfile.txt + call assert_equal(4, getqflist(#{size: v:true}).size, 'with length ' .. len) + endfor + call delete('Xcqetfile.txt') +endfunc + func s:create_test_file(filename) let l = [] for i in range(1, 20) -- cgit