view src/testdir/test_langmap.vim @ 33353:b59205d0567e v9.0.1939

patch 9.0.1939: still a problem when processing LSP RPC requests Commit: https://github.com/vim/vim/commit/b80ae6cec34639abfb1a7080fb633346a81a5770 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sun Sep 24 23:38:46 2023 +0200 patch 9.0.1939: still a problem when processing LSP RPC requests Problem: still a problem when processing LSP RPC requests Solution: When processing async LSP RPC requests, compare sequence numbers only in response messages A LSP request message can be sent to the language server either synchronously (ch_evalexpr) or asynchronously (ch_sendexpr). In both cases, when looking for response messages by using the sequence number, LSP requests messages from the language server with the same sequence number should not be used. Patch 9.0.1927 fixed this issue for synchronous requests. This PR fixes the issue for asynchronous requests and adds additional tests. closes: #13158 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
author Christian Brabandt <cb@256bit.org>
date Sun, 24 Sep 2023 23:45:08 +0200
parents 360f286b5869
children
line wrap: on
line source

" tests for 'langmap'

source check.vim
CheckFeature langmap

func Test_langmap()
  new
  set langmap=}l,^x,%v

  call setline(1, ['abc'])
  call feedkeys('gg0}^', 'tx')
  call assert_equal('ac', getline(1))

  " in Replace mode
  " need silent! to avoid a delay when entering Insert mode
  call setline(1, ['abcde'])
  silent! call feedkeys("gg0lR%{z\<Esc>00", 'tx')
  call assert_equal('a%{ze', getline(1))

  " in Select mode
  " need silent! to avoid a delay when entering Insert mode
  call setline(1, ['abcde'])
  silent! call feedkeys("gg0}%}\<C-G>}^\<Esc>00", 'tx')
  call assert_equal('a}^de', getline(1))

  " Error cases
  call assert_fails('set langmap=aA,b', 'E357:')
  call assert_fails('set langmap=z;y;y;z', 'E358:')

  " Map character > 256
  enew!
  set langmap=āx,ăl,āx
  call setline(1, ['abcde'])
  call feedkeys('gg2lā', 'tx')
  call assert_equal('abde', getline(1))

  " special characters in langmap
  enew!
  call setline(1, ['Hello World'])
  set langmap=\\;\\,,\\,\\;
  call feedkeys('ggfo,', 'tx')
  call assert_equal(8, col('.'))
  call feedkeys(';', 'tx')
  call assert_equal(5, col('.'))
  set langmap&
  set langmap=\\;\\,;\\,\\;
  call feedkeys('ggfo,', 'tx')
  call assert_equal(8, col('.'))
  call feedkeys(';', 'tx')
  call assert_equal(5, col('.'))

  set langmap=RL
  let g:counter = 0
  nnoremap L;L <Cmd>let g:counter += 1<CR>
  nnoremap <C-L> <Cmd>throw 'This mapping should not be triggered'<CR>

  " 'langmap' is applied to keys without modifiers when matching a mapping
  call feedkeys('R;R', 'tx')
  call assert_equal(1, g:counter)
  nunmap L;L
  unlet g:counter

  delete
  call assert_equal('', getline(1))
  undo
  call assert_equal('Hello World', getline(1))
  " 'langmap' does not change Ctrl-R to Ctrl-L for consistency
  call feedkeys("\<*C-R>", 'tx')
  call assert_equal('', getline(1))

  set langmap=6L
  undo
  setlocal bufhidden=hide
  let oldbuf = bufnr()
  enew
  call assert_notequal(oldbuf, bufnr())
  " 'langmap' does not change Ctrl-6 to Ctrl-L for consistency
  " Ctrl-6 becomes Ctrl-^ after merging the Ctrl modifier
  call feedkeys("\<*C-6>", 'tx')
  call assert_equal(oldbuf, bufnr())
  setlocal bufhidden&

  nunmap <C-L>

  set langmap&
  quit!
endfunc

" vim: shiftwidth=2 sts=2 expandtab