It is useful to emulate cmdline.
https://github.com/vim/vim/pull/15040
(7 files)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
@Shougo pushed 1 commit.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.
Thanks. The change to syntax/vim.vim is not needed, we will however need to re-generate the vim.vim syntax script. I wonder what happens, if the autocommand changes the cursor position? Does it recursively trigger the autocommand (I hope not)?
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
I wonder what happens, if the autocommand changes the cursor position? Does it recursively trigger the autocommand (I hope not)?
I have tested the behavior.
If ++nested
is not set, it works without nesting call.
If ++nested
is set, it will be infinite loop.
Found errors in Test_Cmdline():
Caught exception in Test_Cmdline(): Vim(call):E218: Autocommand nesting too deep @ command line..script /home/shougo/src/vim/src/testdir/runtest.vim[607]..func
tion RunTheTest[57]..Test_Cmdline[108]..CmdlineMoved Autocommands for ":"..CmdlineMoved Autocommands for ":"..CmdlineMoved Autocommands for ":"..CmdlineMoved A
utocommands for ":"..CmdlineMoved Autocommands for ":"..CmdlineMoved Autocommands for ":"..CmdlineMoved Autocommands for ":"..CmdlineMoved Autocommands for ":"
..CmdlineMoved Autocommands for ":"..CmdlineMoved Autocommands for ":"
I think it is expected behavior.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
I have added the test for it.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
thanks. I am not a big fan of adding yet another auto command... Wouldn't be CursorMovedC be the better name, that way it would be in more sync to the existing CursorMoved and CursorMovedI autocommands I would think.
Can you please back out the change to syntax/vim.vim and also please rename the auto command?
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
OK.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Can you please back out the change to syntax/vim.vim and also please rename the auto command?
Done.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
thanks!
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
@zeertzjq commented on this pull request.
In src/testdir/test_autocmd.vim:
> @@ -2096,6 +2096,21 @@ func Test_Cmdline() au! CmdlineEnter au! CmdlineLeave let &shellslash = save_shellslash + + au! CursorMovedC : let g:pos = getcmdpos() + let g:pos = 0 + call feedkeys(":hello\<Left>\<ESC>", 'xt') + call assert_equal(5, g:pos) + call feedkeys(":12345678\<C-R>=setcmdpos(3)\<CR>\<ESC>", 'xt') + call assert_equal(3, g:pos) + au! CursorMovedC + + " CursorMovedC changes the cursor position. + au! CursorMovedC : let g:pos = getcmdpos() | call setcmdpos(getcmdpos()-1)
It seems that this test doesn't really make sense, because setcmdpos()
doesn't actually work when called in an autocommand:
Only works while editing the command line, thus you must use
|c_CTRL-\_e|, |c_CTRL-R_=| or |c_CTRL-R_CTRL-R| with '='. For
|c_CTRL-\_e| and |c_CTRL-R_CTRL-R| with '=' the position is
set after the command line is set to the expression. For
|c_CTRL-R_=| it is set after evaluating the expression but
before inserting the resulting text.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
@Shougo commented on this pull request.
In src/testdir/test_autocmd.vim:
> @@ -2096,6 +2096,21 @@ func Test_Cmdline() au! CmdlineEnter au! CmdlineLeave let &shellslash = save_shellslash + + au! CursorMovedC : let g:pos = getcmdpos() + let g:pos = 0 + call feedkeys(":hello\<Left>\<ESC>", 'xt') + call assert_equal(5, g:pos) + call feedkeys(":12345678\<C-R>=setcmdpos(3)\<CR>\<ESC>", 'xt') + call assert_equal(3, g:pos) + au! CursorMovedC + + " CursorMovedC changes the cursor position. + au! CursorMovedC : let g:pos = getcmdpos() | call setcmdpos(getcmdpos()-1)
Hm.... If so, why it is nesting?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
@zeertzjq commented on this pull request.
In src/testdir/test_autocmd.vim:
> @@ -2096,6 +2096,21 @@ func Test_Cmdline() au! CmdlineEnter au! CmdlineLeave let &shellslash = save_shellslash + + au! CursorMovedC : let g:pos = getcmdpos() + let g:pos = 0 + call feedkeys(":hello\<Left>\<ESC>", 'xt') + call assert_equal(5, g:pos) + call feedkeys(":12345678\<C-R>=setcmdpos(3)\<CR>\<ESC>", 'xt') + call assert_equal(3, g:pos) + au! CursorMovedC + + " CursorMovedC changes the cursor position. + au! CursorMovedC : let g:pos = getcmdpos() | call setcmdpos(getcmdpos()-1)
Because you are triggering CursorMovedC
even if cursor didn't move.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
@zeertzjq commented on this pull request.
In src/testdir/test_autocmd.vim:
> @@ -2096,6 +2096,21 @@ func Test_Cmdline() au! CmdlineEnter au! CmdlineLeave let &shellslash = save_shellslash + + au! CursorMovedC : let g:pos = getcmdpos() + let g:pos = 0 + call feedkeys(":hello\<Left>\<ESC>", 'xt') + call assert_equal(5, g:pos) + call feedkeys(":12345678\<C-R>=setcmdpos(3)\<CR>\<ESC>", 'xt') + call assert_equal(3, g:pos) + au! CursorMovedC + + " CursorMovedC changes the cursor position. + au! CursorMovedC : let g:pos = getcmdpos() | call setcmdpos(getcmdpos()-1)
It seems that the initial value of save_cmdspos
is also wrong, as it is using the position from the previous cmdline. I'll fix these problems in #15064.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.
@Shougo commented on this pull request.
In src/testdir/test_autocmd.vim:
> @@ -2096,6 +2096,21 @@ func Test_Cmdline() au! CmdlineEnter au! CmdlineLeave let &shellslash = save_shellslash + + au! CursorMovedC : let g:pos = getcmdpos() + let g:pos = 0 + call feedkeys(":hello\<Left>\<ESC>", 'xt') + call assert_equal(5, g:pos) + call feedkeys(":12345678\<C-R>=setcmdpos(3)\<CR>\<ESC>", 'xt') + call assert_equal(3, g:pos) + au! CursorMovedC + + " CursorMovedC changes the cursor position. + au! CursorMovedC : let g:pos = getcmdpos() | call setcmdpos(getcmdpos()-1)
Oh...
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.