Skip to content

Commit

Permalink
patch 8.2.4719: ">" marker sometimes not displayed in the jumplist
Browse files Browse the repository at this point in the history
Problem:    ">" marker sometimes not displayed in the jumplist.
Solution:   If the buffer no longer exists show "-invalid-". (Christian
            Brabandt, closes #10131, closes #10100)
  • Loading branch information
chrisbra authored and brammool committed Apr 9, 2022
1 parent cee9c84 commit a0f659c
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 17 deletions.
3 changes: 3 additions & 0 deletions runtime/doc/motion.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,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:

Expand Down
4 changes: 4 additions & 0 deletions src/mark.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,10 @@ ex_jumps(exarg_T *eap UNUSED)
{
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))
{
Expand Down
1 change: 0 additions & 1 deletion src/testdir/Make_all.mak
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ NEW_TESTS = \
test_join \
test_json \
test_jumplist \
test_jumps \
test_lambda \
test_langmap \
test_largefile \
Expand Down
1 change: 0 additions & 1 deletion src/testdir/test_alot.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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_move.vim
source test_put.vim
Expand Down
39 changes: 39 additions & 0 deletions src/testdir/test_jumplist.vim
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,43 @@ 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
15 changes: 0 additions & 15 deletions src/testdir/test_jumps.vim

This file was deleted.

2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4719,
/**/
4718,
/**/
Expand Down

0 comments on commit a0f659c

Please sign in to comment.