aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-06-20 12:29:47 +0800
committerGitHub <noreply@github.com>2024-06-20 12:29:47 +0800
commit978b0263f87a2751034d5899017afd3ce61c318e (patch)
treea6f09f17659ebe44bc84df8d7a7301b1f0e7b135 /test
parent3317aa2f3756d21905b501a01d4f2b3203f60943 (diff)
parent99373c8792d1338ea011bf8efc708bb434530d05 (diff)
downloadrneovim-978b0263f87a2751034d5899017afd3ce61c318e.tar.gz
rneovim-978b0263f87a2751034d5899017afd3ce61c318e.tar.bz2
rneovim-978b0263f87a2751034d5899017afd3ce61c318e.zip
Merge pull request #29413 from jiangyinzuo/vim-patch-9.1.0497
vim-patch:partial:9.1.{0497,0501}: termdebug can be further improved
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/test_termdebug.vim66
1 files changed, 65 insertions, 1 deletions
diff --git a/test/old/testdir/test_termdebug.vim b/test/old/testdir/test_termdebug.vim
index 38278cb326..bb107161eb 100644
--- a/test/old/testdir/test_termdebug.vim
+++ b/test/old/testdir/test_termdebug.vim
@@ -280,9 +280,20 @@ func Test_termdebug_mapping()
call assert_equal(':echom "K"<cr>', maparg('K', 'n', 0, 1).rhs)
%bw!
+
+ " -- Test that local-buffer mappings are restored in the correct buffers --
+ " local mappings for foo
+ file foo
nnoremap <buffer> K :echom "bK"<cr>
nnoremap <buffer> - :echom "b-"<cr>
nnoremap <buffer> + :echom "b+"<cr>
+
+ " no mappings for 'bar'
+ enew
+ file bar
+
+ " Start termdebug from foo
+ buffer foo
Termdebug
call WaitForAssert({-> assert_equal(3, winnr('$'))})
wincmd b
@@ -290,15 +301,41 @@ func Test_termdebug_mapping()
call assert_true(maparg('-', 'n', 0, 1).buffer)
call assert_true(maparg('+', 'n', 0, 1).buffer)
call assert_equal(maparg('K', 'n', 0, 1).rhs, ':echom "bK"<cr>')
+
+ Source
+ buffer bar
+ call assert_false(maparg('K', 'n', 0, 1)->empty())
+ call assert_false(maparg('-', 'n', 0, 1)->empty())
+ call assert_false(maparg('+', 'n', 0, 1)->empty())
+ call assert_true(maparg('K', 'n', 0, 1).buffer->empty())
+ call assert_true(maparg('-', 'n', 0, 1).buffer->empty())
+ call assert_true(maparg('+', 'n', 0, 1).buffer->empty())
wincmd t
quit!
redraw!
call WaitForAssert({-> assert_equal(1, winnr('$'))})
+
+ " Termdebug session ended. Buffer 'bar' shall have no mappings
+ call assert_true(bufname() ==# 'bar')
+ call assert_false(maparg('K', 'n', 0, 1)->empty())
+ call assert_false(maparg('-', 'n', 0, 1)->empty())
+ call assert_false(maparg('+', 'n', 0, 1)->empty())
+ call assert_true(maparg('K', 'n', 0, 1).buffer->empty())
+ call assert_true(maparg('-', 'n', 0, 1).buffer->empty())
+ call assert_true(maparg('+', 'n', 0, 1).buffer->empty())
+
+ " Buffer 'foo' shall have the same mapping as before running the termdebug
+ " session
+ buffer foo
+ call assert_true(bufname() ==# 'foo')
call assert_true(maparg('K', 'n', 0, 1).buffer)
call assert_true(maparg('-', 'n', 0, 1).buffer)
call assert_true(maparg('+', 'n', 0, 1).buffer)
call assert_equal(':echom "bK"<cr>', maparg('K', 'n', 0, 1).rhs)
+ nunmap K
+ nunmap +
+ nunmap -
%bw!
endfunc
@@ -341,14 +378,41 @@ func Test_termdebug_bufnames()
endfunc
function Test_termdebug_save_restore_variables()
+ " saved mousemodel
let &mousemodel=''
+
+ " saved keys
+ nnoremap K :echo "hello world!"<cr>
+ let expected_map_K = maparg('K', 'n', 0 , 1)
+ nnoremap + :echo "hello plus!"<cr>
+ let expected_map_plus = maparg('+', 'n', 0 , 1)
+ let expected_map_minus = {}
+
+ " saved &columns
+ let expected_columns = &columns
+
+ " We want termdebug to overwrite 'K' map but not '+' map.
+ let g:termdebug_config = {}
+ let g:termdebug_config['map_K'] = 1
+
Termdebug
call WaitForAssert({-> assert_equal(3, winnr('$'))})
call WaitForAssert({-> assert_match(&mousemodel, 'popup_setpos')})
wincmd t
quit!
call WaitForAssert({-> assert_equal(1, winnr('$'))})
- call WaitForAssert({-> assert_true(empty(&mousemodel))})
+
+ call assert_true(empty(&mousemodel))
+
+ call assert_true(empty(expected_map_minus))
+ call assert_equal(expected_map_K.rhs, maparg('K', 'n', 0, 1).rhs)
+ call assert_equal(expected_map_plus.rhs, maparg('+', 'n', 0, 1).rhs)
+
+ call assert_equal(expected_columns, &columns)
+
+ nunmap K
+ nunmap +
+ unlet g:termdebug_config
endfunction