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(select_hunk): compatible with <cmd> mapping #1200

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

xzbdmw
Copy link
Contributor

@xzbdmw xzbdmw commented Feb 4, 2025

Previous type vih will only select hunk lines which are below current line with mapping like
map({ "o", "x" }, "ih", "<cmd>Gitsigns select_hunk<CR>").
Also update the readme to use the faster <cmd> mapping.

@lewis6991
Copy link
Owner

Can you explain an example this fixes?

I can't remember exactly why, but I think I specifically avoided using <cmd> for this mapping.

@xzbdmw
Copy link
Contributor Author

xzbdmw commented Feb 4, 2025

iShot_2025-02-04_23.43.44.mp4

In this video I'm typing vih with <cmd> mapping.

I can't remember exactly why, but I think I specifically avoided using for this mapping.

This pr also works for lua functions such as

                map({ "o", "x" }, "ih", function()
                    gs.select_hunk()
                end)

@lewis6991
Copy link
Owner

vih works fine for me. I'm not sure what this PR fixes.

@xzbdmw
Copy link
Contributor Author

xzbdmw commented Feb 5, 2025

It only works if the mapping uses : to enter command mode, but not when the mapping is function callback form or cmd form. Here is a video show why the original one does not work when start at visual mode, I'm simulating vim.cmd('normal! ' .. hunk.added.start .. 'GV' .. hunk.vend .. 'G') here:

iShot_2025-02-06_01.18.24.mp4

@lewis6991
Copy link
Owner

So this change doesn't actually fix anything it just makes <cmd> work?

@lewis6991 lewis6991 merged commit 8974fd3 into lewis6991:main Feb 6, 2025
7 checks passed
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.

2 participants