]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1899: tabpanel: getcmdscreenpos() wrong when tabpanel is shown v9.1.1899
authorHirohito Higashi <h.east.727@gmail.com>
Sat, 8 Nov 2025 17:12:57 +0000 (17:12 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 8 Nov 2025 17:12:57 +0000 (17:12 +0000)
Problem:  tabpanel: getcmdscreenpos() wrong when tabpanel is shown
Solution: Adjust f_getcmdscreenpos() and add cmdline_col_off
          (Hirohito Higashi)

related: #18678
closes: #18699

Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/ex_getln.c
src/testdir/test_tabpanel.vim
src/version.c

index 63e9814546cafa6e2a40820be51658c2fb057043..4ebfbfc5e4fba476595659d3323e2762e964d87e 100644 (file)
@@ -4481,7 +4481,7 @@ f_getcmdscreenpos(typval_T *argvars UNUSED, typval_T *rettv)
 {
     cmdline_info_T *p = get_ccline_ptr();
 
-    rettv->vval.v_number = p != NULL ? p->cmdspos + 1 : 0;
+    rettv->vval.v_number = p != NULL ? cmdline_col_off + p->cmdspos + 1 : 0;
 }
 
 /*
index acf0ea94bd9af1e3a77a985929e348ccc515830f..4959693260778ff00b24d6150c60992c12e356af 100644 (file)
@@ -94,6 +94,45 @@ function Test_tabpanel_with_vsplit()
   call StopVimInTerminal(buf)
 endfunc
 
+func Call_cmd_funcs()
+  let g:results = [getcmdpos(), getcmdscreenpos(), getcmdline()]
+endfunc
+
+function Test_tabpanel_cmdline()
+  let save_showtabline = &showtabline
+  let g:results = []
+  cnoremap <expr> <F2> Call_cmd_funcs()
+
+  set showtabline=0 showtabpanel=0
+  call Call_cmd_funcs()
+  call assert_equal([0, 0, ''], g:results)
+  call feedkeys(":\<F2>\<Esc>", "xt")
+  call assert_equal([1, 2, ''], g:results)
+  call feedkeys(":pwd\<F2>\<Esc>", "xt")
+  call assert_equal([4, 5, 'pwd'], g:results)
+
+  set showtabline=2 showtabpanel=2 tabpanelopt=columns:20,align:left
+  call Call_cmd_funcs()
+  call assert_equal([0, 0, ''], g:results)
+  call feedkeys(":\<F2>\<Esc>", "xt")
+  call assert_equal([1, 22, ''], g:results)
+  call feedkeys(":pwd\<F2>\<Esc>", "xt")
+  call assert_equal([4, 25, 'pwd'], g:results)
+
+  set showtabline=2 showtabpanel=2 tabpanelopt+=align:right
+  call Call_cmd_funcs()
+  call assert_equal([0, 0, ''], g:results)
+  call feedkeys(":\<F2>\<Esc>", "xt")
+  call assert_equal([1, 2, ''], g:results)
+  call feedkeys(":pwd\<F2>\<Esc>", "xt")
+  call assert_equal([4, 5, 'pwd'], g:results)
+
+  unlet g:results
+  cunmap <F2>
+  call s:reset()
+  let &showtabline = save_showtabline
+endfunc
+
 function Test_tabpanel_mouse()
   let save_showtabline = &showtabline
   let save_mouse = &mouse
index adf5f22684c3cc7e6983f5e993bda81aa39fb3a7..a95d332c3805fdbdf47689a0919a855bed157a87 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1899,
 /**/
     1898,
 /**/