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

In visual mode, which key seems to make cursor jump before command actually executed #241

Open
zhyzky opened this issue Aug 11, 2023 · 4 comments

Comments

@zhyzky
Copy link

zhyzky commented Aug 11, 2023

Warning: if you don't fill this issue template and provide the reproducible steps the issue could be closed directly.

Environment (please complete the following information):

  • OS: ubuntu 22.04

  • Vim version: 8.2

  • vim-which-key version: ea87707

  • Have you reproduced with a minimal vimrc: No

Describe the bug
When in visual mode, after which-key hint pops, and just before the actual command executed. You may notice that the cursor jumps at the beginning of line.

To Reproduce
Steps to reproduce the behavior:

  1. Create a vimrc

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

@zhyzky
Copy link
Author

zhyzky commented Aug 11, 2023

This issue not happens on windows.
the config file:

nnoremap
xnoremap
let g:mapleader = " "
let g:maplocalleader = ','
nnoremap :WhichKey ''
nnoremap :WhichKey ','
vnoremap :WhichKeyVisual ''
call which_key#register('', "g:which_key_map")
let g:which_key_map={}

nmap aa MarkSet
xmap aa MarkSet
nmap ar MarkRegex
xmap ar MarkRegex
nmap ad MarkClear
nmap ac :nohMarkAllClear
xmap ac :nohMarkAllClear
nmap as MarkSearchAnyNext
nmap aS MarkSearchAnyPrev
nmap an MarkSearchCurrentNext
nmap aN MarkSearchCurrentPrev

let g:which_key_map['a']={
\ 'name': '+Mark',
\ 'a': 'Mark current',
\ 'r': 'Mark regex',
\ 'd': 'Mark remove',
\ 'c': 'Clear all mark',
\ 's': 'Next mark',
\ 'S': 'Prev mark',
\ 'n': 'CurrentMark Next',
\ 'N': 'CurrentMark Prev',
\ }

@zhyzky
Copy link
Author

zhyzky commented Aug 11, 2023

After some investigation, the issue seems related to: autoload/which_key.vim, line 403,
where a line number add before the Cmd.
Not Sure What's going on with the line range here

@tkapias
Copy link

tkapias commented Dec 2, 2023

I confirm the same issue, it's impossible to use a selected range.

I did not use VWK on the selection before but I would like to sort a spaced list inside a range on the same line.

  • Without VWK the command affect the current selection in visual mode and it works:
vnoremap <F2> d:execute 'normal a' . join(uniq(sort(split(getreg('"')))), ' ')<CR>
  • But with VWK, pressing the leader key exits the selection and affect only the cursor location. It would work if it affected the last selection, but I don't know how. Should I put '<,'> somewhere?
let g:which_key_map_visual.n.s    = 'sort+uniq(spacedWords)'
vnoremap <Leader>ns d:execute 'normal a' . join(uniq(sort(split(getreg('"')))), ' ')<CR>

@zhyzky
Copy link
Author

zhyzky commented Dec 4, 2023

I confirm the same issue, it's impossible to use a selected range.

I did not use VWK on the selection before but I would like to sort a spaced list inside a range on the same line.

  • Without VWK the command affect the current selection in visual mode and it works:
vnoremap <F2> d:execute 'normal a' . join(uniq(sort(split(getreg('"')))), ' ')<CR>
  • But with VWK, pressing the leader key exits the selection and affect only the cursor location. It would work if it affected the last selection, but I don't know how. Should I put '<,'> somewhere?
let g:which_key_map_visual.n.s    = 'sort+uniq(spacedWords)'
vnoremap <Leader>ns d:execute 'normal a' . join(uniq(sort(split(getreg('"')))), ' ')<CR>

Maybe you can just comment out the line " let Cmd = line('v').','.line('.').Cmd "
Didn't get the purpose of line range here, there might be some side effect, though I havn't met yet.

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