]> granicus.if.org Git - vim/commitdiff
patch 8.2.1781: writing to prompt buffer interferes with insert mode v8.2.1781
authorBram Moolenaar <Bram@vim.org>
Thu, 1 Oct 2020 18:03:04 +0000 (20:03 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 1 Oct 2020 18:03:04 +0000 (20:03 +0200)
Problem:    Writing to prompt buffer interferes with insert mode.
Solution:   Use win_enter() instead of just setting "curwin". (Ben Jackson,
            closes #7035)

src/autocmd.c
src/testdir/test_prompt_buffer.vim
src/version.c

index d5c61ca6ac613605aac571e29a549dfe874bda0e..4c2b70596392d4e9adab8d131a7de8e9b4f024c8 100644 (file)
@@ -1533,7 +1533,7 @@ win_found:
        unblock_autocmds();
 
        if (win_valid(aco->save_curwin))
-           curwin = aco->save_curwin;
+           win_enter(aco->save_curwin, TRUE);
        else
            // Hmm, original window disappeared.  Just use the first one.
            curwin = firstwin;
index 365687511dff5088f5ac04d8b8ed33cd5d22d40a..8c266ebe6f228b94c128cd4aaee32e431967ba76 100644 (file)
@@ -182,4 +182,37 @@ func Test_prompt_buffer_getbufinfo()
   %bwipe!
 endfunc
 
+function! Test_prompt_while_writing_to_hidden_buffer()
+  call CanTestPromptBuffer()
+  CheckUnix
+
+  " Make a job continuously write to a hidden buffer, check that the prompt
+  " buffer is not affected.
+  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.1;
+        \ done'], #{out_io: 'buffer', out_name: ''})
+    startinsert
+  END
+  eval 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))})
+  call term_sendkeys(buf, 'test')
+  call WaitForAssert({-> assert_equal('cmd:testtest', term_getline(buf, 1))})
+  call term_sendkeys(buf, 'test')
+  call WaitForAssert({-> assert_equal('cmd:testtesttest', term_getline(buf, 1))})
+
+  call StopVimInTerminal(buf)
+  call delete(scriptName)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index bbe6dd5a6008e302ea6cb960a8a83498d264cce2..01271861863b7b4c663bf82a005ee2975cbf4e09 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1781,
 /**/
     1780,
 /**/