]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1728: termdebug: cannot evaluate visual selected expression v9.1.1728
authorbennyyip <yebenmy@gmail.com>
Tue, 2 Sep 2025 18:06:20 +0000 (20:06 +0200)
committerChristian Brabandt <cb@256bit.org>
Tue, 2 Sep 2025 18:06:20 +0000 (20:06 +0200)
Problem:  termdebug: cannot evaluate visual selected expression
Solution: Add support for visual mode, mapped to K by default (bennyyip)

closes: #18184

Signed-off-by: bennyyip <yebenmy@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/terminal.txt
runtime/pack/dist/opt/termdebug/plugin/termdebug.vim
src/testdir/test_plugin_termdebug.vim
src/version.c

index 2ca2d4be6f2c51b216f55d66bc7aa5e53c870d52..eda0b8d4896795b40e5ac6406f799870b163556d 100644 (file)
@@ -1,4 +1,4 @@
-*terminal.txt* For Vim version 9.1.  Last change: 2025 Jul 08
+*terminal.txt* For Vim version 9.1.  Last change: 2025 Sep 02
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -1467,7 +1467,8 @@ Inspecting variables ~
  `:Evaluate`       evaluate the expression under the cursor
  `K`               same (see |termdebug_map_K| to disable)
  `:Evaluate` {expr}   evaluate {expr}
- `:'<,'>Evaluate`     evaluate the Visually selected text
+ `:'<,'>Evaluate`
+ `{Visual}K`          evaluate the Visually selected text
 
 This is similar to using "print" in the gdb window.
 You can usually shorten `:Evaluate` to `:Ev`.
index e96ec749bd11dd9dd7bb8ed364490681479e6ee6..3be4b135fd5c3306ffd43f50aadcc47536eaa267 100644 (file)
@@ -4,7 +4,7 @@ vim9script
 
 # Author: Bram Moolenaar
 # Copyright: Vim license applies, see ":help license"
-# Last Change: 2025 Aug 24
+# Last Change: 2025 Sep 02
 # Converted to Vim9: Ubaldo Tiberi <ubaldo.tiberi@gmail.com>
 
 # WORK IN PROGRESS - The basics works stable, more to come
@@ -139,6 +139,7 @@ var winbar_winids: list<number>
 var saved_mousemodel: string
 
 var saved_K_map: dict<any>
+var saved_visual_K_map: dict<any>
 var saved_plus_map: dict<any>
 var saved_minus_map: dict<any>
 
@@ -218,6 +219,7 @@ def InitScriptVariables()
   saved_K_map = maparg('K', 'n', false, true)
   saved_plus_map = maparg('+', 'n', false, true)
   saved_minus_map = maparg('-', 'n', false, true)
+  saved_visual_K_map = maparg('K', 'x', false, true)
 
   if has('menu')
     saved_mousemodel = &mousemodel
@@ -1204,6 +1206,9 @@ def InstallCommands()
     if !empty(saved_K_map) && !saved_K_map.buffer || empty(saved_K_map)
       nnoremap K :Evaluate<CR>
     endif
+    if !empty(saved_visual_K_map) && !saved_visual_K_map.buffer || empty(saved_visual_K_map)
+      xnoremap K :Evaluate<CR>
+    endif
   endif
 
   map = true
@@ -1299,6 +1304,12 @@ def DeleteCommands()
     silent! nunmap K
   endif
 
+  if !empty(saved_visual_K_map) && !saved_visual_K_map.buffer
+    mapset(saved_visual_K_map)
+  elseif empty(saved_visual_K_map)
+    silent! xunmap K
+  endif
+
   if !empty(saved_plus_map) && !saved_plus_map.buffer
     mapset(saved_plus_map)
   elseif empty(saved_plus_map)
index 166f4f8663e64818d93ac7646d6b65823633ae03..fa7dd13bdfbb3625682d9423e18c396cb514f899 100644 (file)
@@ -367,6 +367,7 @@ endfunc
 func Test_termdebug_mapping()
   %bw!
   call assert_true(maparg('K', 'n', 0, 1)->empty())
+  call assert_true(maparg('K', 'x', 0, 1)->empty())
   call assert_true(maparg('-', 'n', 0, 1)->empty())
   call assert_true(maparg('+', 'n', 0, 1)->empty())
   Termdebug
@@ -374,6 +375,7 @@ func Test_termdebug_mapping()
   call WaitForAssert({-> assert_equal(3, winnr('$'))})
   wincmd b
   call assert_false(maparg('K', 'n', 0, 1)->empty())
+  call assert_false(maparg('K', 'x', 0, 1)->empty())
   call assert_false(maparg('-', 'n', 0, 1)->empty())
   call assert_false(maparg('+', 'n', 0, 1)->empty())
   call assert_false(maparg('K', 'n', 0, 1).buffer)
@@ -385,11 +387,13 @@ func Test_termdebug_mapping()
   redraw!
   call WaitForAssert({-> assert_equal(1, winnr('$'))})
   call assert_true(maparg('K', 'n', 0, 1)->empty())
+  call assert_true(maparg('K', 'x', 0, 1)->empty())
   call assert_true(maparg('-', 'n', 0, 1)->empty())
   call assert_true(maparg('+', 'n', 0, 1)->empty())
 
   %bw!
   nnoremap K :echom "K"<cr>
+  xnoremap K :<C-U>echom "VK"<cr>
   nnoremap - :echom "-"<cr>
   nnoremap + :echom "+"<cr>
   Termdebug
@@ -397,9 +401,11 @@ func Test_termdebug_mapping()
   call WaitForAssert({-> assert_equal(3, winnr('$'))})
   wincmd b
   call assert_false(maparg('K', 'n', 0, 1)->empty())
+  call assert_false(maparg('K', 'x', 0, 1)->empty())
   call assert_false(maparg('-', 'n', 0, 1)->empty())
   call assert_false(maparg('+', 'n', 0, 1)->empty())
   call assert_false(maparg('K', 'n', 0, 1).buffer)
+  call assert_false(maparg('K', 'x', 0, 1).buffer)
   call assert_false(maparg('-', 'n', 0, 1).buffer)
   call assert_false(maparg('+', 'n', 0, 1).buffer)
   call assert_equal(':Evaluate<CR>', maparg('K', 'n', 0, 1).rhs)
@@ -408,12 +414,15 @@ func Test_termdebug_mapping()
   redraw!
   call WaitForAssert({-> assert_equal(1, winnr('$'))})
   call assert_false(maparg('K', 'n', 0, 1)->empty())
+  call assert_false(maparg('K', 'x', 0, 1)->empty())
   call assert_false(maparg('-', 'n', 0, 1)->empty())
   call assert_false(maparg('+', 'n', 0, 1)->empty())
   call assert_false(maparg('K', 'n', 0, 1).buffer)
+  call assert_false(maparg('K', 'x', 0, 1).buffer)
   call assert_false(maparg('-', 'n', 0, 1).buffer)
   call assert_false(maparg('+', 'n', 0, 1).buffer)
   call assert_equal(':echom "K"<cr>', maparg('K', 'n', 0, 1).rhs)
+  call assert_equal(':<C-U>echom "VK"<cr>', maparg('K', 'x', 0, 1).rhs)
 
   %bw!
 
index 7221f48235198ccd1b55a8d48cb6dbf7d20e87ee..c26e95b92314323242e63788e967f6509f9331f0 100644 (file)
@@ -724,6 +724,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1728,
 /**/
     1727,
 /**/