jumplist: browser-style (or 'tagstack') navigation #11530

Traditionally, when navigating to a specific location from the middle of
the jumplist results in shifting the current location to the bottom of
the list and adding the new location after it.  This behavior is not
desireable to all users--see, for example
https://vi.stackexchange.com/questions/18344/how-to-change-jumplist-behavior.

Here, another jumplist behavior is introduced.  When jumpoptions (a new
option set added here) includes stack, the jumplist behaves like the
tagstack or like history in a web browser.  That is, when navigating to
a location from the middle of the jumplist

    2 first
    1 second
    0 third <-- current location
    1 fourth
    2 fifth

to a new location the locations after the current location in the jump
list are discarded

    2 first
    1 second
    0 third
            <-- current location

The result is that when moving forward from that location, the new
location will be appended to the jumplist:

    3 first
    2 second
    1 third
    0 new

If the new location is the same

  new == second

as some previous (but not immediately prior) entry in the jumplist,

    2 first
    1 second
    0 third <-- current location
    1 fourth
    2 fifth

both occurrences preserved

    3 first
    2 second
    1 third
    0 second (new)

when moving forward from that location.

It would be desireable to go farther and, when the new location is the
same as the location that is currently next in the jumplist,

    new == fourth

make the result of navigating to the new location by jumping (e.g. 50gg)
be the same as moving forward in the jumplist

    2 first
    1 second
    0 third
    1 new <-- current location
    2 fifth

and simply increment the jumplist index.  That change is NOT part of
this patch because it would require passing the new cursor location to
the function (setpcmark) from all of its callees.  That in turn would
require those callees to know *before* calling what the new cursor
location is, which do they do not currently.
This commit is contained in:
butwerenotthereyet
2019-12-10 00:56:56 -08:00
committed by Justin M. Keyes
parent 6c22c7ab97
commit 39094b3fae
9 changed files with 205 additions and 3 deletions

View File

@@ -1299,6 +1299,14 @@ return {
varname='p_js',
defaults={if_true={vi=true}}
},
{
full_name='jumpoptions', abbreviation='jop',
type='string', list='onecomma', scope={'global'},
deny_duplicates=true,
varname='p_jop',
vim=true,
defaults={if_true={vim=''}}
},
{
full_name='keymap', abbreviation='kmp',
type='string', scope={'buffer'},