aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/quickfix.c8
-rw-r--r--src/nvim/testdir/test_quickfix.vim13
2 files changed, 19 insertions, 2 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 6ca97c3072..d3ca65c53c 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -3975,11 +3975,15 @@ static void qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last)
*dirname = NUL;
// Add one line for each error
- if (old_last == NULL || old_last->qf_next == NULL) {
+ if (old_last == NULL) {
qfp = qfl->qf_start;
lnum = 0;
} else {
- qfp = old_last->qf_next;
+ if (old_last->qf_next != NULL) {
+ qfp = old_last->qf_next;
+ } else {
+ qfp = old_last;
+ }
lnum = buf->b_ml.ml_line_count;
}
while (lnum < qfl->qf_count) {
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim
index 049163890e..3e97cd2dd0 100644
--- a/src/nvim/testdir/test_quickfix.vim
+++ b/src/nvim/testdir/test_quickfix.vim
@@ -4410,4 +4410,17 @@ func Test_search_in_dirstack()
call delete('Xtestdir', 'rf')
endfunc
+" Test for adding an invalid entry with the quickfix window open and making
+" sure that the window contents are not changed
+func Test_add_invalid_entry_with_qf_window()
+ call setqflist([], 'f')
+ cexpr "Xfile1:10:aa"
+ copen
+ call setqflist(['bb'], 'a')
+ call assert_equal(1, line('$'))
+ call assert_equal(['Xfile1|10| aa'], getline(1, '$'))
+ call assert_equal([{'lnum': 10, 'bufnr': bufnr('Xfile1'), 'col': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': 'aa'}], getqflist())
+ cclose
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab