Mercurial > vim
comparison src/testdir/test_prompt_buffer.vim @ 26280:b93e176e7998 v8.2.3671
patch 8.2.3671: restarting Insert mode in prompt buffer too often
Commit: https://github.com/vim/vim/commit/34c20ff85b87be587ea5d0398812441b502ee6a5
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Nov 25 13:04:48 2021 +0000
patch 8.2.3671: restarting Insert mode in prompt buffer too often
Problem: Restarting Insert mode in prompt buffer too often when a callback
switches windows and comes back. (Sean Dewar)
Solution: Do not set "restart_edit" when already in Insert mode.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 25 Nov 2021 14:15:03 +0100 |
parents | 13812db714fa |
children | 457ea0570b6f |
comparison
equal
deleted
inserted
replaced
26279:63fc72609797 | 26280:b93e176e7998 |
---|---|
37 \ ' call append(line("$") - 1, "Result: \"" . a:text . "\"")', | 37 \ ' call append(line("$") - 1, "Result: \"" . a:text . "\"")', |
38 \ ' " Reset &modified to allow the buffer to be closed.', | 38 \ ' " Reset &modified to allow the buffer to be closed.', |
39 \ ' set nomodified', | 39 \ ' set nomodified', |
40 \ 'endfunc', | 40 \ 'endfunc', |
41 \ '', | 41 \ '', |
42 \ 'func SwitchWindows()', | |
43 \ ' call timer_start(0, {-> execute("wincmd p|wincmd p", "")})', | |
44 \ 'endfunc', | |
45 \ '', | |
42 \ 'call setline(1, "other buffer")', | 46 \ 'call setline(1, "other buffer")', |
43 \ 'set nomodified', | 47 \ 'set nomodified', |
44 \ 'new', | 48 \ 'new', |
45 \ 'set buftype=prompt', | 49 \ 'set buftype=prompt', |
46 \ 'call prompt_setcallback(bufnr(""), function("TextEntered"))', | 50 \ 'call prompt_setcallback(bufnr(""), function("TextEntered"))', |
92 call term_sendkeys(buf, end . "x") | 96 call term_sendkeys(buf, end . "x") |
93 call WaitForAssert({-> assert_equal('cmd: -hzelx', term_getline(buf, 1))}) | 97 call WaitForAssert({-> assert_equal('cmd: -hzelx', term_getline(buf, 1))}) |
94 | 98 |
95 call term_sendkeys(buf, "\<C-U>exit\<CR>") | 99 call term_sendkeys(buf, "\<C-U>exit\<CR>") |
96 call WaitForAssert({-> assert_equal('other buffer', term_getline(buf, 1))}) | 100 call WaitForAssert({-> assert_equal('other buffer', term_getline(buf, 1))}) |
101 | |
102 call StopVimInTerminal(buf) | |
103 call delete(scriptName) | |
104 endfunc | |
105 | |
106 func Test_prompt_switch_windows() | |
107 call CanTestPromptBuffer() | |
108 let scriptName = 'XpromptSwitchWindows' | |
109 call WriteScript(scriptName) | |
110 | |
111 let buf = RunVimInTerminal('-S ' . scriptName, {'rows': 12}) | |
112 call WaitForAssert({-> assert_equal('cmd:', term_getline(buf, 1))}) | |
113 call WaitForAssert({-> assert_match('-- INSERT --', term_getline(buf, 12))}) | |
114 | |
115 call term_sendkeys(buf, "\<C-O>:call SwitchWindows()\<CR>") | |
116 call term_wait(buf, 50) | |
117 call WaitForAssert({-> assert_match('-- INSERT --', term_getline(buf, 12))}) | |
118 | |
119 call term_sendkeys(buf, "\<Esc>") | |
120 call term_wait(buf, 50) | |
121 call WaitForAssert({-> assert_match('^ *$', term_getline(buf, 12))}) | |
97 | 122 |
98 call StopVimInTerminal(buf) | 123 call StopVimInTerminal(buf) |
99 call delete(scriptName) | 124 call delete(scriptName) |
100 endfunc | 125 endfunc |
101 | 126 |