diff src/testdir/test_paste.vim @ 28627:da77eb586899 v8.2.4837

patch 8.2.4837: modifiers not simplified when timed out Commit: https://github.com/vim/vim/commit/68a573ce2b996602a86b14d9b258ebb8c657604f Author: zeertzjq <zeertzjq@outlook.com> Date: Thu Apr 28 14:10:01 2022 +0100 patch 8.2.4837: modifiers not simplified when timed out Problem: Modifiers not simplified when timed out or using feedkeys() with 'n" flag. Solution: Adjust how mapped flag and timeout are used. (closes #10305)
author Bram Moolenaar <Bram@vim.org>
date Thu, 28 Apr 2022 15:15:03 +0200
parents 7976d709c963
children 457ea0570b6f
line wrap: on
line diff
--- a/src/testdir/test_paste.vim
+++ b/src/testdir/test_paste.vim
@@ -2,6 +2,7 @@
 
 " Bracketed paste only works with "xterm".  Not in GUI or Windows console.
 source check.vim
+source term_util.vim
 CheckNotMSWindows
 CheckNotGui
 
@@ -217,6 +218,69 @@ func Test_pastetoggle()
   bwipe!
 endfunc
 
+func Test_pastetoggle_timeout_no_typed_after_mapped()
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+    set pastetoggle=abc
+    set ttimeoutlen=10000
+    imap d a
+  END
+  call writefile(lines, 'Xpastetoggle_no_typed_after_mapped.vim')
+  let buf = RunVimInTerminal('-S Xpastetoggle_no_typed_after_mapped.vim', #{rows: 8})
+  call TermWait(buf)
+  call term_sendkeys(buf, ":call feedkeys('id', 't')\<CR>")
+  call term_wait(buf, 200)
+  call term_sendkeys(buf, 'bc')
+  " 'ttimeoutlen' should NOT apply
+  call WaitForAssert({-> assert_match('^-- INSERT --', term_getline(buf, 8))})
+
+  call StopVimInTerminal(buf)
+  call delete('Xpastetoggle_no_typed_after_mapped.vim')
+endfunc
+
+func Test_pastetoggle_timeout_typed_after_mapped()
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+    set pastetoggle=abc
+    set ttimeoutlen=10000
+    imap d a
+  END
+  call writefile(lines, 'Xpastetoggle_typed_after_mapped.vim')
+  let buf = RunVimInTerminal('-S Xpastetoggle_typed_after_mapped.vim', #{rows: 8})
+  call TermWait(buf)
+  call term_sendkeys(buf, ":call feedkeys('idb', 't')\<CR>")
+  call term_wait(buf, 200)
+  call term_sendkeys(buf, 'c')
+  " 'ttimeoutlen' should apply
+  call WaitForAssert({-> assert_match('^-- INSERT (paste) --', term_getline(buf, 8))})
+
+  call StopVimInTerminal(buf)
+  call delete('Xpastetoggle_typed_after_mapped.vim')
+endfunc
+
+func Test_pastetoggle_timeout_typed_after_noremap()
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+    set pastetoggle=abc
+    set ttimeoutlen=10000
+    inoremap d a
+  END
+  call writefile(lines, 'Xpastetoggle_typed_after_noremap.vim')
+  let buf = RunVimInTerminal('-S Xpastetoggle_typed_after_noremap.vim', #{rows: 8})
+  call TermWait(buf)
+  call term_sendkeys(buf, ":call feedkeys('idb', 't')\<CR>")
+  call term_wait(buf, 200)
+  call term_sendkeys(buf, 'c')
+  " 'ttimeoutlen' should apply
+  call WaitForAssert({-> assert_match('^-- INSERT (paste) --', term_getline(buf, 8))})
+
+  call StopVimInTerminal(buf)
+  call delete('Xpastetoggle_typed_after_noremap.vim')
+endfunc
+
 " Test for restoring option values when 'paste' is disabled
 func Test_paste_opt_restore()
   set autoindent expandtab ruler showmatch