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

feat: utilize last window cursor position #2416

Merged

Conversation

jamestrew
Copy link
Contributor

closes #2386

Description

When using pickers to open buffers, fallback on window's last cursor position for that buffer.
This preserves the cursor location (row and col) for previously opened buffers.

This only impacts the column location for the buffers picker. But currently also impact the line number as well for find_files. This last point might be too disruptive even though I believe the change is for the better. I can modify the PR to revert this however.

Fixes # (issue)
#2386

Type of change

  • New feature (non-breaking change which adds functionality) MOSTLY

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list relevant details about your configuration

  • Feature Test
  • open a buffer and move the cursor to somewhere not [1,1]
  • open a new split :vnew
  • :Telescope buffers and open the buffer from above -> cursor should be in the same location between the two windows (previously would always go to the 1st column)
  • open a new split :vnew
  • :Telescope find_files and open the buffer from above -> cursor should be in the same location between the windows (previously would always go to [1,1]) -> this behavior MAY be consider too drastic
  • Regression Test (ensure buffer pickers with provided row/col info is putting the cursor in an expected position)
  • open a buffer and move the cursor to somewhere not [1,1]
  • :Telescope live_grep and grep for some random word in that buffer not under the cursor of that buffer
  • note the cursor position in the results list and select the entry
  • cursor should move to the expected location

Configuration:

  • Neovim version (nvim --version):
NVIM v0.9.0-dev-1070+g2630341db
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
  • Operating system and version: Linux archlinux 6.1.12-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 14 Feb 2023 22:08:08 +0000 x86_64 GNU/Linux

Checklist:

  • My code follows the style guidelines of this project (stylua)
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (lua annotations)

@tjdevries tjdevries merged commit 98f9d5f into nvim-telescope:master Mar 21, 2023
@tjdevries
Copy link
Member

Thanks, LGTM

Conni2461 pushed a commit that referenced this pull request Apr 9, 2023
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.

Add option to remember column number in buffer picker
2 participants