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

fix: do not change the jumplist when using to a line in a file #2910

Merged
merged 1 commit into from
Feb 4, 2024

Conversation

mdedonno1337
Copy link
Contributor

@mdedonno1337 mdedonno1337 commented Feb 4, 2024

Description

While using some Telescope commands that jump directly to a line in a file (like tags), the function first opens the file, then call norm! gg and search for the target line.
This will include the top of the file in the jumplist.

Since the top of the file is not jumped-to by user, it's not a position that the user cares about; it would make sense to not include this position in the jumplist.

Reproduce the bug

To see this behaviour, open a file, call the Telescope tags command, select and confirm any tag that is in the middle of a big file (i.e. when the target tag is jumped-to, the top of the file (line 1) should ideally not be visible), then press Ctrl-O to go back in the first file you edited just before the Telescope tags invocation.
This will not set you back in the first file, but at the top of the file containing the target tag.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

I've used this patch for a while in my normal workflow, to ensure no obvious problems arise.

Configuration

NVIM v0.9.5
AppImage

Debian 12

Copy link
Contributor

@jamestrew jamestrew left a comment

Choose a reason for hiding this comment

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

thank you thank you

@jamestrew jamestrew merged commit 2360838 into nvim-telescope:master Feb 4, 2024
6 checks passed
Conni2461 pushed a commit that referenced this pull request Mar 11, 2024
@LEXUGE
Copy link

LEXUGE commented Jul 22, 2024

Seems like due to this change the builtins.current_buffer_fuzzy_find will not append the jump list upon jumping. I don't think this is the expected behavior as the jump is user-initiated in this case.

@jamestrew
Copy link
Contributor

@LEXUGE I think this PR will address this. Are you able to confirm?
#3205

@LEXUGE
Copy link

LEXUGE commented Jul 22, 2024

I will test later when I am free

@dhananjaylatkar
Copy link
Contributor

edit is not called when item is selected in builtins.current_buffer_fuzzy_find.

Following change is required to fix buffer_fuzzy_find jumplist -

diff --git a/lua/telescope/builtin/__files.lua b/lua/telescope/builtin/__files.lua
index 2a3f2ce..4de397e 100644
--- a/lua/telescope/builtin/__files.lua
+++ b/lua/telescope/builtin/__files.lua
@@ -564,6 +564,7 @@ files.current_buffer_fuzzy_find = function(opts)

           actions.close(prompt_bufnr)
           vim.schedule(function()
+            vim.cmd [[normal! m']]
             vim.api.nvim_win_set_cursor(0, { selection.lnum, first_col })
           end)
         end)

@jamestrew
Copy link
Contributor

@dhananjaylatkar thanks I'll look into this & your PR later today

@jamestrew
Copy link
Contributor

@LEXUGE should be fixed in #3219

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.

4 participants