Skip to content
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

Feature: Set jumplist before jumping #305

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wbthomason
Copy link

Closes #266. We may also want to add a configuration parameter if users should be able to disable/enable this behavior, but I think it's a reasonable enough default that it may be OK to wait for complaints before adding this.

I have not tested this extensively with weird window options/layouts, etc., but it has worked for my basic use case.

Co-authored-by: max397574 <81827001+max397574@users.noreply.github.com>
Copy link
Owner

@stevearc stevearc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some notes about edge cases.

I will note that I did a couple of tests myself just playing around with setting the ' mark, and had trouble getting it to behave correctly. I didn't look into it too much, but it's entirely possible that setting the marks this way via the API behaves differently than when you do it via the m' normal mode command.


if opts.jump then
local old_cursor = vim.api.nvim_win_get_cursor(winid)
vim.api.nvim_buf_set_mark(vim.api.nvim_get_current_buf(), [[']], unpack(old_cursor))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize for the terrible naming, this API needs some refactoring. The "jump" parameter doesn't mean what you think it means. When it's true, it means that we will focus the source window as part of this navigation action. So when you're just navigating around within the same buffer using :AerialNext/Prev, this value will be false.

Another thing to note: we're jumping to a location in winid, but winid is not necessarily the active window right here. You'll probably need to use nvim_win_get_buf() for the buffer, and you might need to do a nvim_win_call as well to make sure the mark is set in the appropriate window. If you want to test it, I would expect this to come up if your cursor is in the aerial window when you run :AerialNext/Prev.

@yalikebaz
Copy link

Just wanted to nudge this a little, would be super helpful to have jumplist integrated here 🙏
if not... I've customized my telescope picker to somewhat look like AerialToggle, and this works with the jumplist by default:

:lua require('telescope').extensions.aerial.aerial(require('telescope.themes').get_dropdown({layout_strategy='vertical', layout_config={vertical={anchor='E', width=0.2, height=0.9}}, previewer=false, sorting_strategy='ascending', results_title=false, prompt_title=false, border=false}))<CR>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: store locations in jumplist
4 participants