-
Notifications
You must be signed in to change notification settings - Fork 40
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
any way to trigger CursorMoved in a test? #2
Comments
Hmm, I wasn't aware of the issue, but it seems to be the case and I have no idea if it's possible to change the behavior. Given that, I guess the only way we can test CursorMoved event is to manually trigger it with Execute (setup):
let g:cnt = 0
augroup CursorMovedTest
autocmd!
autocmd CursorMoved * let g:cnt += 1
augroup END
Given:
hello world
Do:
llllx
:doautocmd CursorMoved\<CR>
Expect:
hell world
Execute (cleanup):
" 1 not 5 :/
AssertEqual 1, g:cnt
augroup CursorMovedTest
autocmd!
augroup END
augroup! CursorMovedTest |
|
caveat: CursorMoved is not triggered in scripts/macros, so we must force it. junegunn/vader.vim#2
Just for reference: this is not possible to test in Vader, because Vim itself does not appear to have any tests for Reminded me of #124, where (Neo)Vim wrapped in tmux could be used for tests like these. But then it might be better to add support to Vim/Neovim for triggering a main loop iteration / autocommands check manually (via some option, so it would not be necessary to have an equivalent of |
Is that really different than manually triggering the event loop? :) |
What I've meant was that you could set an option in test/vimrc which would trigger the event-checking part of the main loop after each command in a script (automatically). Took me a while to figure this out however. |
From what I can tell after reading docs/web, cursor movement in a script or macro, such as Vader, does not trigger the CursorMoved event.
:help CursorMoved
actually says something briefly on this:So testing effects of a CursorMoved autocmd in Vader seems impossible, but hopefully I'm wrong. I've tried breaking up the moving in separate
normal
commands, and even tried things like this:Since
inputsave()
clears the "typeahead", I was hopeing this would allow the test to triggerCursorMoved
. But it doesn't.You can verify the general problem with these commands:
"hi" is not echoed, though if the user typed
lh
in normal mode, it would be echoed.Any ideas? I will ping the vim_use mailing list too.
Thanks!
The text was updated successfully, but these errors were encountered: