-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
mode()
incorrectly reports current mode
#8342
Comments
@lacygoill I came up with the mwe following your help on my last issue report but I am not too confident about my vim9script skills. |
mode()
incorrectly reports current modemode()
incorrectly reports current mode
Yes, it seems that vim9script
snoremap <expr> s- execute('g:mode = mode(1)')->slice(0, 0)
xnoremap <expr> X- execute('g:mode = mode(1)')->slice(0, 0)
feedkeys('ghs-', 'x')
assert_equal('s', g:mode)
feedkeys("\<C-g>X-", 'x')
assert_equal('v', g:mode)
echom v:errors
|
At the second feedkeys() select mode is not active, it works OK when it first starts select mode with "gh". |
Ah yes, the contents of vim9script
snoremap <expr> s- execute('g:mode = mode(1)')->slice(0, 0)
xnoremap <expr> X- execute('g:mode = mode(1)')->slice(0, 0)
feedkeys('ghs-', 'x')
assert_equal('s', g:mode)
unlet g:mode
feedkeys("\<C-g>X-", 'x')
assert_equal('v', g:mode)
echom v:errors
OK, so this explains what the OP observed. I guess it's working as intended. |
To the OP, you can work around this issue by using the special keycode
Write this:
|
Thanks to both of you. This is very helpful. |
Describe the bug
Mode incorrectly reported using
mode()
.To Reproduce
Detailed steps to reproduce the behavior:
vim -Nu NONE -S mwe.vim9
wheremwe.vim9
is<C-g>
we left select mode to go to visual.Therefore the
mode()
invokation (via mappingX-
) should return visual mode.Note that the
X-
(visual only) mapping seems to be triggered correctly though.Expected behavior
The last assert of
mwe.vim9
should fail.Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: