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

leap-forward-x and selection=exclusive #52

Open
nkgm opened this issue Sep 25, 2022 · 6 comments
Open

leap-forward-x and selection=exclusive #52

nkgm opened this issue Sep 25, 2022 · 6 comments

Comments

@nkgm
Copy link

nkgm commented Sep 25, 2022

Right now leap-forward-x lands 1 char short in visual mode when selection=exclusive. I'm assuming this isn't intended behavior as leap-forward does the right thing.

And thanks for this plugin :)

@ggandor
Copy link
Owner

ggandor commented Sep 25, 2022

I don't understand the issue, they work consistently. Targeting ar:
leap-forward + sel=exclusive -> foob|ar
leap-forward + sel=inclusive -> fooba|r
leap-forward-x + sel=exclusive -> fooba|r
leap-forward-x + sel=inclusive -> foobar|

And thanks for this plugin :)

Thanks :)

@nkgm
Copy link
Author

nkgm commented Sep 25, 2022

I would like to contrast this behavior to vim's own t, f:

vta + sel=exclusive -> foob|ar
vta + sel=inclusive -> foo|b|ar
Effective selection is foob in both cases.

vfa + sel=exclusive -> fooba|r
vfa + sel=inclusive -> foob|a|r
Effective selection is fooba in both cases.

I would expect Leap to follow the same principle, so that leap-forward + ar is always foob|ar and leap-forward-x + ar is always foobar|.

@ggandor
Copy link
Owner

ggandor commented Sep 26, 2022

vta + sel=exclusive -> foob|ar
vta + sel=inclusive -> foo|b|ar
Effective selection is foob in both cases.

No. vta + sel=exclusive is foo|bar (it would yank foo), vfa + sel=exclusive is foob|ar (yanks foob). What would be the point of the selection flag otherwise? Making it dependent on the method you used to define the selection would be beyond confusing. Motion commands move the cursor to somewhere. selection is only interested in where the cursor actually is. It's that simple. The two should have nothing to do with each other.

@nkgm
Copy link
Author

nkgm commented Sep 26, 2022

vta + sel=exclusive is foo|bar (it would yank foo)

vim vta
vta always yanks foob regardless of sel.

vfa + sel=exclusive is foob|ar (yanks foob)

vim vfa
vfa always yanks fooba regardless of sel.

Edit:
Different values of sel become relevant in backwards motions ie T, F eg:

vim vFf
vFf + sel=exclusive -> fooba
vFf + sel=inclusive -> foobar

@ggandor
Copy link
Owner

ggandor commented Sep 26, 2022

I stand corrected. I tried this on vanilla Vim, but on Nvim f and t indeed behave as you described, and seem to ignore selection.

I cannot see this documented anywhere though. I've read through :h vim-diff.txt and :h visual.txt, and also tried to search for relevant Nvim issues. It seems like a bug to me. All other motions, like w or / work as expected, taking the value of selection into account.

@nkgm
Copy link
Author

nkgm commented Sep 28, 2022

I tried this on vanilla Vim

Are you sure? I tried this on vanilla Vim and it produced the same yanks (the caret moves an extra char to the right under sel=exclusive but it's the same yank).

Either way this issue is more of an exercise in Vim as I'm well aware I can do my custom motions in Leap thanks to its excellent API, however every now and then I find myself indulging in conversation about such aspects of Vim as some things still fail to make sense to me. For instance dw and vwd will give different results under sel=inclusive. I'm sure there's "reasons", but from a usability perspective this is insane as you have to keep the various edge cases in mind depending on where your are in a file and what mode you're in, what direction you're going etc (end-of-line is another favorite). It would make way more sense to always use sel=exclusive with ve=onemore with a custom e-like motion mapped to a "smart" el (to always land 1 char past the end of a word so that a subsequent vb highlights the entire word), but I digress!

@nkgm nkgm closed this as not planned Won't fix, can't repro, duplicate, stale Oct 7, 2022
@ggandor ggandor reopened this Oct 7, 2022
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

No branches or pull requests

2 participants