-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jumplist: browser-style (or 'tagstack') navigation #11530
Conversation
40916de
to
5cc2e5d
Compare
Looks good except:
|
yes. Also, calling this "history" is pretty misleading since that could describe the old behavior as well. Perhaps "stack" is a better term? Browser-like behavior pops items off the stack, whereas Vim-like behavior is always additive. In fact, this essentially makes ctrl-o/ctrl-i behave like the 'tagstack', which (as mentioned in https://vi.stackexchange.com/q/18344/578 ) is what |
Agreed, "stack" fits much better with existing Vim terminology. The option is now ( 3aca2ea )
The first-pass on the documentation now mentions that adding |
1c912dd
to
0aacabc
Compare
src/nvim/mark.c
Outdated
@@ -1204,16 +1214,27 @@ void cleanup_jumplist(win_T *wp, bool checktail) | |||
break; | |||
} | |||
} | |||
if (i >= wp->w_jumplistlen) { // no duplicate | |||
bool mustfree = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a "dead assignment", static analysis will flag it.
bool mustfree = false; | |
bool mustfree; |
I would probably lean towards a ternary or some other way to be less verbose in the logic below, but I suppose that could turn out worse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the dead store in 7f29497 . The less verbose versions I've been able to come up with so far have been less readable (highly subjective), but if there's a better way to write this let's do it.
0aacabc
to
7f29497
Compare
ab58f93
to
452656d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Nice attention to detail--thanks for taking care about formatting the tests and other details :)
todo: mention this in vim_diff.txt
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.
452656d
to
0c59972
Compare
@justinmk Thank you for all the guidance.
There's now a mention of |
This comment has been minimized.
This comment has been minimized.
Is the following the traditional behavior?
|
Almost like this |
Problem: not possible to use the jumplist like a stack Solution: Add the 'jumpoptions' setting to make the jumplist a stack. Add an option for using jumplist like tag stack related: #7738 closes: #13134 ported from NeoVim: - https://neovim.io/doc/user/motion.html#jumplist-stack - neovim/neovim@39094b3 - neovim/neovim#11530 - https://vi.stackexchange.com/questions/18344/how-to-change-jumplist-behavior Based on the feedback in the previous PR, it looks like many people like this option. Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com> Co-authored-by: butwerenotthereyet <58348703+butwerenotthereyet@users.noreply.github.com>
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 g:jumplistmode is set to "history", the jumplist behaves like history of a web browser. When navigating to a location from the middle of the jumplist
to a location that is different from the location that is currently next in the jumplist
the locations after the current location in the jump list are discarded
The result is that when moving forward from that location, the new location will be appended to the jumplist:
If the new location is the same
new == second
as some previous (but not immediately prior) entry in the jumplist,
both occurrences preserved
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,
make the result of navigating to the new location by navigating directly (e.g. 50gg) be the same as moving forward in the jumplist
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 they do not currently.