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
Unexpectedly leaving insert mode when job writes to hidden buffer using prompt buffers (regression by patch 8.2.1654) #7035
Comments
I'm surprised patch 8.6.1654 would cause this, and only now gets reported. |
I can check but I bisected and it indicated the above commit. I can confirm that with 8.2.1762 we no longer have the pum left open, but it still exits insert mode unexpectedly. With 8.1.1654, you end up with both - exit insert mode unexpectedly and the pum is left open. |
:set timeout? timeoutlen? ttimeout? ttimeoutlen? (including the question marks)? Best regards, |
Will check motif GUI at work tomorrow, sorry don't have a gvim here right now. For the record, it does repro in MacVim (GUI) with:
|
On Mon, Sep 28, 2020 at 11:23 PM Ben Jackson ***@***.***> wrote:
Does it happen also in gvim?
Will check motif GUI at work tomorrow, sorry don't have a gvim here right
now.
For the record, it *does* repro in MacVim with:
***@***.*** vim-clean % gvim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep 28 2020 22:02:11)
macOS version
Included patches: 1-1768
Compiled by Homebrew
Huge version with MacVim GUI. Features included (+) or not (-):
What are the answers to :set timeout? timeoutlen? ttimeout? ttimeoutlen?
[image: Screenshot 2020-09-28 at 22 21 56]
<https://user-images.githubusercontent.com/10584846/94487504-09dde480-01d9-11eb-8c34-ec4fec370429.png>
- timeout
- timeoutlen=1000
- ttimeout
- ttimeoutlen=100
Hm, with the above settings, Vim ought to be able to tell the difference
between an Esc key hit at the keyboard and a ^[ sent as part of a keycode,
so I suppose it isn't that. Also, if the problem happens in the MacVim GUI
I would expect it to happen also in an X11 or W32/64 GUI but I'm less sure
about that.
Best regards,
Tony.
|
Yes Tony I’m fairly sure that this is not a mapping issue. It’s as if something is calling stopinsert. I have a couple of theories of how to minimise the repro case. Will try after work hopefully. Re the point about being not reported before, it seems that it’s only prompt buffers that are affected, which are not frequently used. |
OK, this is easy to repro. Here's a trivial case. set buftype=prompt
call prompt_setprompt( bufnr(), 'Enter some text: ' )
call job_start( [ 'uuencode', '/dev/urandom', '/dev/stdout' ], #{
\ out_io: 'buffer',
\ out_name: ''
\ } )
|
Here's a test that repros it:
|
Been debugging this. I'm thinking that it's related to this:
When using For certain when we do call Are we missing a call to |
I can't reproduce because "uuencode: Command not found". Perhaps something more common (and not keeping the CPU busy)? |
Oh, and there is no aucmd_prepwin(), you probably mean aucmd_prepbuf(). But it doesn't call leaving_window() directly. |
Just need a job to write to a hidden buffer while in insert mode. This repro's it too
this seems to resolve it:
|
Yeah I meant |
OK here's a test which repros it too; had to introduce some sleeps though :/ function! Test_Prompt_While_Writing_To_Hidden_Buffer()
call CanTestPromptBuffer()
let scriptName = 'XpromptscriptHiddenBuf'
let script =<< trim END
set buftype=prompt
call prompt_setprompt( bufnr(), 'cmd:' )
let job = job_start( [ '/bin/sh', '-c', 'while true; do echo line; sleep 0.2; done' ], #{
\ out_io: 'buffer',
\ out_name: '' } )
startinsert
END
exec script->writefile( scriptName )
let buf = RunVimInTerminal('-S ' . scriptName, {})
call WaitForAssert({-> assert_equal('cmd:', term_getline(buf, 1))})
call term_sendkeys( buf, 'test' )
call WaitForAssert( {-> assert_equal('cmd:test', term_getline(buf, 1)) } )
sleep 10m
call term_sendkeys( buf, 'test' )
call WaitForAssert( {-> assert_equal('cmd:testtest', term_getline(buf, 1)) } )
sleep 10m
call term_sendkeys( buf, 'test' )
call WaitForAssert( {-> assert_equal('cmd:testtesttest', term_getline(buf, 1)) } )
call StopVimInTerminal(buf)
call delete(scriptName)
endfunc |
I was wondering if this patch (that I just made myself when I first encountered the bug) is useful: I have no idea if this is the "right" solution or not, just figured I'd show what I was thinking. I just expected |
Just so no one is confused about @puremourning 's test script, I believe you are calling helper functions from the vimspector plugin, puremourning? EDIT: if you can upload your full script (and dependencies), it could help us run your test case 👍 |
@happy-dude my test runs in Vim’s test suite. Paste it into Those functions are defined in vim’s shared.vim and friends. |
Thanks for figuring this out and writing a test. I'll clean it up a bit. |
Thanks Bram. That's working nice now. |
Problem: Writing to prompt buffer interferes with insert mode. Solution: Use win_enter() instead of just setting "curwin". (Ben Jackson, closes vim/vim#7035) vim/vim@4537bcc Patch v8.2.1783 has fixes.
Problem: Writing to prompt buffer interferes with insert mode. Solution: Use win_enter() instead of just setting "curwin". (Ben Jackson, closes vim/vim#7035) vim/vim@4537bcc
Problem: Writing to prompt buffer interferes with insert mode. Solution: Use win_enter() instead of just setting "curwin". (Ben Jackson, closes vim/vim#7035) vim/vim@4537bcc
Problem: Writing to prompt buffer interferes with insert mode. Solution: Use win_enter() instead of just setting "curwin". (Ben Jackson, closes vim/vim#7035) vim/vim@4537bcc
Problem: Writing to prompt buffer interferes with insert mode. Solution: Use win_enter() instead of just setting "curwin". (Ben Jackson, closes vim/vim#7035) vim/vim@4537bcc
Problem: Writing to prompt buffer interferes with insert mode. Solution: Use win_enter() instead of just setting "curwin". (Ben Jackson, closes vim/vim#7035) vim/vim@4537bcc
Problem: Writing to prompt buffer interferes with insert mode. Solution: Use win_enter() instead of just setting "curwin". (Ben Jackson, closes vim/vim#7035) vim/vim@4537bcc
Problem: Writing to prompt buffer interferes with insert mode. Solution: Use win_enter() instead of just setting "curwin". (Ben Jackson, closes vim/vim#7035) vim/vim@4537bcc
Problem: Writing to prompt buffer interferes with insert mode. Solution: Use win_enter() instead of just setting "curwin". (Ben Jackson, closes vim/vim#7035) vim/vim@4537bcc Vim test will be skipped, so add a Lua test. The problem boils down to the use of aucmd_restbuf in a callback, so just test that (via nvim_buf_set_lines).
Problem: Writing to prompt buffer interferes with insert mode. Solution: Use win_enter() instead of just setting "curwin". (Ben Jackson, closes vim/vim#7035) vim/vim@4537bcc Vim test will be skipped, so add a Lua test. The problem boils down to the use of aucmd_restbuf in a callback, so just test that (via nvim_buf_set_lines).
Problem: Writing to prompt buffer interferes with insert mode. Solution: Use win_enter() instead of just setting "curwin". (Ben Jackson, closes vim/vim#7035) vim/vim@4537bcc Vim test will be skipped, so add a Lua test. The problem boils down to the use of aucmd_restbuf in a callback, so just test that (via nvim_buf_set_lines).
Problem: Writing to prompt buffer interferes with insert mode. Solution: Use win_enter() instead of just setting "curwin". (Ben Jackson, closes vim/vim#7035) vim/vim@4537bcc Vim test will be skipped, so add a Lua test. The problem boils down to the use of aucmd_restbuf in a callback, so just test that (via nvim_buf_set_lines).
Describe the bug
After patch 8.2.1654, insert mode is exited unexpectedly using prompt-buffers when a job writes to a hidden buffer.
I used the repro case to bisect this to 8.2.1654 patch.
To Reproduce
Detailed steps to reproduce the behavior:
test.vim
vim -Nu NONE -S test.vim
i
You will be bumped unexpectedly out of insert mode into normal mode as you're typing.
Expected behavior
Remain in insert mode until pressing
<CR>
in the prompt buffer.Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: