mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 05:05:00 -07:00
Merge pull request #29413 from jiangyinzuo/vim-patch-9.1.0497
vim-patch:partial:9.1.{0497,0501}: termdebug can be further improved
This commit is contained in:
commit
978b0263f8
@ -462,6 +462,9 @@ If there is no g:termdebug_config you can use: >vim
|
|||||||
let g:termdebug_use_prompt = 1
|
let g:termdebug_use_prompt = 1
|
||||||
<
|
<
|
||||||
Mappings ~
|
Mappings ~
|
||||||
|
The termdebug plugin enables a few default mappings. All those mappings
|
||||||
|
are reset to their original values once the termdebug session concludes.
|
||||||
|
|
||||||
*termdebug_map_K* *termdebug-mappings*
|
*termdebug_map_K* *termdebug-mappings*
|
||||||
The K key is normally mapped to |:Evaluate| unless a buffer local (|:map-local|)
|
The K key is normally mapped to |:Evaluate| unless a buffer local (|:map-local|)
|
||||||
mapping to K already exists. If you do not want this use: >vim
|
mapping to K already exists. If you do not want this use: >vim
|
||||||
|
@ -168,7 +168,7 @@ func s:StartDebug_internal(dict)
|
|||||||
let b:save_signcolumn = &signcolumn
|
let b:save_signcolumn = &signcolumn
|
||||||
let s:signcolumn_buflist = [bufnr()]
|
let s:signcolumn_buflist = [bufnr()]
|
||||||
|
|
||||||
let s:save_columns = 0
|
let s:saved_columns = 0
|
||||||
let s:allleft = v:false
|
let s:allleft = v:false
|
||||||
let wide = 0
|
let wide = 0
|
||||||
if exists('g:termdebug_config')
|
if exists('g:termdebug_config')
|
||||||
@ -178,7 +178,7 @@ func s:StartDebug_internal(dict)
|
|||||||
endif
|
endif
|
||||||
if wide > 0
|
if wide > 0
|
||||||
if &columns < wide
|
if &columns < wide
|
||||||
let s:save_columns = &columns
|
let s:saved_columns = &columns
|
||||||
let &columns = wide
|
let &columns = wide
|
||||||
" If we make the Vim window wider, use the whole left half for the debug
|
" If we make the Vim window wider, use the whole left half for the debug
|
||||||
" windows.
|
" windows.
|
||||||
@ -808,8 +808,8 @@ func s:EndDebugCommon()
|
|||||||
|
|
||||||
call win_gotoid(curwinid)
|
call win_gotoid(curwinid)
|
||||||
|
|
||||||
if s:save_columns > 0
|
if s:saved_columns > 0
|
||||||
let &columns = s:save_columns
|
let &columns = s:saved_columns
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if exists('#User#TermdebugStopPost')
|
if exists('#User#TermdebugStopPost')
|
||||||
@ -1028,8 +1028,8 @@ func s:InstallCommands()
|
|||||||
let map = g:termdebug_map_K
|
let map = g:termdebug_map_K
|
||||||
endif
|
endif
|
||||||
if map
|
if map
|
||||||
let s:k_map_saved = maparg('K', 'n', 0, 1)
|
let s:saved_K_map = maparg('K', 'n', 0, 1)
|
||||||
if !empty(s:k_map_saved) && !s:k_map_saved.buffer || empty(s:k_map_saved)
|
if !empty(s:saved_K_map) && !s:saved_K_map.buffer || empty(s:saved_K_map)
|
||||||
nnoremap K :Evaluate<CR>
|
nnoremap K :Evaluate<CR>
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -1039,8 +1039,8 @@ func s:InstallCommands()
|
|||||||
let map = get(g:termdebug_config, 'map_plus', 1)
|
let map = get(g:termdebug_config, 'map_plus', 1)
|
||||||
endif
|
endif
|
||||||
if map
|
if map
|
||||||
let s:plus_map_saved = maparg('+', 'n', 0, 1)
|
let s:saved_plus_map = maparg('+', 'n', 0, 1)
|
||||||
if !empty(s:plus_map_saved) && !s:plus_map_saved.buffer || empty(s:plus_map_saved)
|
if !empty(s:saved_plus_map) && !s:saved_plus_map.buffer || empty(s:saved_plus_map)
|
||||||
nnoremap <expr> + $'<Cmd>{v:count1}Up<CR>'
|
nnoremap <expr> + $'<Cmd>{v:count1}Up<CR>'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -1050,8 +1050,8 @@ func s:InstallCommands()
|
|||||||
let map = get(g:termdebug_config, 'map_minus', 1)
|
let map = get(g:termdebug_config, 'map_minus', 1)
|
||||||
endif
|
endif
|
||||||
if map
|
if map
|
||||||
let s:minus_map_saved = maparg('-', 'n', 0, 1)
|
let s:saved_minus_map = maparg('-', 'n', 0, 1)
|
||||||
if !empty(s:minus_map_saved) && !s:minus_map_saved.buffer || empty(s:minus_map_saved)
|
if !empty(s:saved_minus_map) && !s:saved_minus_map.buffer || empty(s:saved_minus_map)
|
||||||
nnoremap <expr> - $'<Cmd>{v:count1}Down<CR>'
|
nnoremap <expr> - $'<Cmd>{v:count1}Down<CR>'
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -1119,32 +1119,32 @@ func s:DeleteCommands()
|
|||||||
delcommand Var
|
delcommand Var
|
||||||
delcommand Winbar
|
delcommand Winbar
|
||||||
|
|
||||||
if exists('s:k_map_saved')
|
if exists('s:saved_K_map')
|
||||||
if !empty(s:k_map_saved) && !s:k_map_saved.buffer
|
if !empty(s:saved_K_map) && !s:saved_K_map.buffer
|
||||||
nunmap K
|
nunmap K
|
||||||
call mapset(s:k_map_saved)
|
call mapset(s:saved_K_map)
|
||||||
elseif empty(s:k_map_saved)
|
elseif empty(s:saved_K_map)
|
||||||
nunmap K
|
nunmap K
|
||||||
endif
|
endif
|
||||||
unlet s:k_map_saved
|
unlet s:saved_K_map
|
||||||
endif
|
endif
|
||||||
if exists('s:plus_map_saved')
|
if exists('s:saved_plus_map')
|
||||||
if !empty(s:plus_map_saved) && !s:plus_map_saved.buffer
|
if !empty(s:saved_plus_map) && !s:saved_plus_map.buffer
|
||||||
nunmap +
|
nunmap +
|
||||||
call mapset(s:plus_map_saved)
|
call mapset(s:saved_plus_map)
|
||||||
elseif empty(s:plus_map_saved)
|
elseif empty(s:saved_plus_map)
|
||||||
nunmap +
|
nunmap +
|
||||||
endif
|
endif
|
||||||
unlet s:plus_map_saved
|
unlet s:saved_plus_map
|
||||||
endif
|
endif
|
||||||
if exists('s:minus_map_saved')
|
if exists('s:saved_minus_map')
|
||||||
if !empty(s:minus_map_saved) && !s:minus_map_saved.buffer
|
if !empty(s:saved_minus_map) && !s:saved_minus_map.buffer
|
||||||
nunmap -
|
nunmap -
|
||||||
call mapset(s:minus_map_saved)
|
call mapset(s:saved_minus_map)
|
||||||
elseif empty(s:minus_map_saved)
|
elseif empty(s:saved_minus_map)
|
||||||
nunmap -
|
nunmap -
|
||||||
endif
|
endif
|
||||||
unlet s:minus_map_saved
|
unlet s:saved_minus_map
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if has('menu')
|
if has('menu')
|
||||||
|
@ -280,9 +280,20 @@ func Test_termdebug_mapping()
|
|||||||
call assert_equal(':echom "K"<cr>', maparg('K', 'n', 0, 1).rhs)
|
call assert_equal(':echom "K"<cr>', maparg('K', 'n', 0, 1).rhs)
|
||||||
|
|
||||||
%bw!
|
%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> K :echom "bK"<cr>
|
||||||
nnoremap <buffer> - :echom "b-"<cr>
|
nnoremap <buffer> - :echom "b-"<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
|
Termdebug
|
||||||
call WaitForAssert({-> assert_equal(3, winnr('$'))})
|
call WaitForAssert({-> assert_equal(3, winnr('$'))})
|
||||||
wincmd b
|
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_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>')
|
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
|
wincmd t
|
||||||
quit!
|
quit!
|
||||||
redraw!
|
redraw!
|
||||||
call WaitForAssert({-> assert_equal(1, winnr('$'))})
|
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('K', 'n', 0, 1).buffer)
|
||||||
call assert_true(maparg('-', 'n', 0, 1).buffer)
|
call assert_true(maparg('-', '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)
|
call assert_equal(':echom "bK"<cr>', maparg('K', 'n', 0, 1).rhs)
|
||||||
|
|
||||||
|
nunmap K
|
||||||
|
nunmap +
|
||||||
|
nunmap -
|
||||||
%bw!
|
%bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
@ -341,14 +378,41 @@ func Test_termdebug_bufnames()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
function Test_termdebug_save_restore_variables()
|
function Test_termdebug_save_restore_variables()
|
||||||
|
" saved mousemodel
|
||||||
let &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
|
Termdebug
|
||||||
call WaitForAssert({-> assert_equal(3, winnr('$'))})
|
call WaitForAssert({-> assert_equal(3, winnr('$'))})
|
||||||
call WaitForAssert({-> assert_match(&mousemodel, 'popup_setpos')})
|
call WaitForAssert({-> assert_match(&mousemodel, 'popup_setpos')})
|
||||||
wincmd t
|
wincmd t
|
||||||
quit!
|
quit!
|
||||||
call WaitForAssert({-> assert_equal(1, winnr('$'))})
|
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
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user