diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-04-10 07:13:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-10 07:13:22 +0800 |
commit | ff726cc569994aab61a42c40270e679dc80cca7c (patch) | |
tree | ded66b1e5369b72d27cacaa91efc09d3daaa7394 | |
parent | 12662ac0c4160b81f7875909d765cf8526bbdef2 (diff) | |
download | rneovim-ff726cc569994aab61a42c40270e679dc80cca7c.tar.gz rneovim-ff726cc569994aab61a42c40270e679dc80cca7c.tar.bz2 rneovim-ff726cc569994aab61a42c40270e679dc80cca7c.zip |
vim-patch:8.2.4719: ">" marker sometimes not displayed in the jumplist (#18056)
Problem: ">" marker sometimes not displayed in the jumplist.
Solution: If the buffer no longer exists show "-invalid-". (Christian
Brabandt, closes vim/vim#10131, closes vim/vim#10100)
https://github.com/vim/vim/commit/a0f659c76e22108880f857b8961422afc5ed8f5d
Add a modeline to test_jumplist.vim
-rw-r--r-- | runtime/doc/motion.txt | 3 | ||||
-rw-r--r-- | src/nvim/mark.c | 5 | ||||
-rw-r--r-- | src/nvim/testdir/test_alot.vim | 1 | ||||
-rw-r--r-- | src/nvim/testdir/test_jumplist.vim | 41 | ||||
-rw-r--r-- | src/nvim/testdir/test_jumps.vim | 11 |
5 files changed, 49 insertions, 12 deletions
diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt index 20033bd76a..2cc6842402 100644 --- a/runtime/doc/motion.txt +++ b/runtime/doc/motion.txt @@ -1044,6 +1044,9 @@ The "file/text" column shows the file name, or the text at the jump if it is in the current file (an indent is removed and a long line is truncated to fit in the window). +The marker ">" indicates the current position in the jumplist. It may not be +shown when filtering the |:jump| command using |:filter| + You are currently in line 1167. If you then use the CTRL-O command, the cursor is put in line 1154. This results in: diff --git a/src/nvim/mark.c b/src/nvim/mark.c index b770fef05c..6790bf8240 100644 --- a/src/nvim/mark.c +++ b/src/nvim/mark.c @@ -844,6 +844,11 @@ void ex_jumps(exarg_T *eap) if (curwin->w_jumplist[i].fmark.mark.lnum != 0) { name = fm_getname(&curwin->w_jumplist[i].fmark, 16); + // Make sure to output the current indicator, even when on an wiped + // out buffer. ":filter" may still skip it. + if (name == NULL && i == curwin->w_jumplistidx) { + name = vim_strsave((char_u *)"-invalid-"); + } // apply :filter /pat/ or file name not available if (name == NULL || message_filtered(name)) { xfree(name); diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index bb744f7b41..43a519bc84 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -16,7 +16,6 @@ source test_fnamemodify.vim source test_ga.vim source test_glob2regpat.vim source test_global.vim -source test_jumps.vim source test_lispwords.vim source test_menu.vim source test_move.vim diff --git a/src/nvim/testdir/test_jumplist.vim b/src/nvim/testdir/test_jumplist.vim index 9cfbbe2029..91ad940e18 100644 --- a/src/nvim/testdir/test_jumplist.vim +++ b/src/nvim/testdir/test_jumplist.vim @@ -64,3 +64,44 @@ func Test_getjumplist() call delete("Xtest") endfunc + +func Test_jumplist_invalid() + new + clearjumps + " put some randome text + put ='a' + let prev = bufnr('%') + setl nomodified bufhidden=wipe + e XXJumpListBuffer + let bnr = bufnr('%') + " 1) empty jumplist + let expected = [[ + \ {'lnum': 2, 'bufnr': prev, 'col': 0, 'coladd': 0}], 1] + call assert_equal(expected, getjumplist()) + let jumps = execute(':jumps') + call assert_equal('>', jumps[-1:]) + " now jump back + exe ":norm! \<c-o>" + let expected = [[ + \ {'lnum': 2, 'bufnr': prev, 'col': 0, 'coladd': 0}, + \ {'lnum': 1, 'bufnr': bnr, 'col': 0, 'coladd': 0}], 0] + call assert_equal(expected, getjumplist()) + let jumps = execute(':jumps') + call assert_match('> 0 2 0 -invalid-', jumps) +endfunc + +" Test for '' mark in an empty buffer + +func Test_empty_buffer() + new + insert +a +b +c +d +. + call assert_equal(1, line("''")) + bwipe! +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_jumps.vim b/src/nvim/testdir/test_jumps.vim deleted file mode 100644 index 5a3717d165..0000000000 --- a/src/nvim/testdir/test_jumps.vim +++ /dev/null @@ -1,11 +0,0 @@ -func Test_empty_buffer() - new - insert -a -b -c -d -. - call assert_equal(1, line("''")) - bwipe! -endfunc |