aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYinzuo Jiang <jiangyinzuo@foxmail.com>2024-06-20 10:44:11 +0800
committerYinzuo Jiang <jiangyinzuo@foxmail.com>2024-06-20 10:49:24 +0800
commit99373c8792d1338ea011bf8efc708bb434530d05 (patch)
tree783df07afc30de276feca6aabcd67191c73de995
parentb48192af37aa39d55e73420e3838cb63f471da99 (diff)
downloadrneovim-99373c8792d1338ea011bf8efc708bb434530d05.tar.gz
rneovim-99373c8792d1338ea011bf8efc708bb434530d05.tar.bz2
rneovim-99373c8792d1338ea011bf8efc708bb434530d05.zip
vim-patch:partial:9.1.0501: too complicated mapping restore in termdebug
Problem: too complicated mapping restore in termdebug Solution: simplify unmapping logic, add a few more tests (Ubaldo Tiberi) closes: vim/vim#15046 https://github.com/vim/vim/commit/46f2823807741ac91c51cf36ddabf293db26ab41 Co-authored-by: Ubaldo Tiberi <ubaldo.tiberi@google.com>
-rw-r--r--test/old/testdir/test_termdebug.vim37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/old/testdir/test_termdebug.vim b/test/old/testdir/test_termdebug.vim
index c84478fefa..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