From 48a4657aee76e41d097b0730c91bcca78b5bc9c7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 23 Aug 2022 08:36:22 +0800 Subject: vim-patch:8.1.{1915,1921,1953} (#19900) vim-patch:8.1.1915: more functions can be used as methods Problem: More functions can be used as methods. Solution: Make various functions usable as a method. https://github.com/vim/vim/commit/1a3a89168d61c2fed91cbca812cf1c6983901b79 Move debugbreak() to the right place. vim-patch:8.1.1921: more functions can be used as methods Problem: More functions can be used as methods. Solution: Make various functions usable as a method. https://github.com/vim/vim/commit/a4208966fb289a505ebdef62bbc37c214069bab4 vim-patch:8.1.1953: more functions can be used as a method Problem: More functions can be used as a method. Solution: Allow more functions to be used as a method. https://github.com/vim/vim/commit/f9f24ce7a0e5988fedf2e2ff751818f9b07510a6 Omit test_termcodes.vim: cannot be used and superseded by later patches. Cherry-pick test_bufline.vim change from patch 8.1.1993. --- src/nvim/testdir/test_cursor_func.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir/test_cursor_func.vim') diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim index 3b8a5f27ad..f13842edc8 100644 --- a/src/nvim/testdir/test_cursor_func.vim +++ b/src/nvim/testdir/test_cursor_func.vim @@ -22,7 +22,7 @@ func Test_move_cursor() call cursor(3, 0) call assert_equal([3, 1, 0, 1], getcurpos()[1:]) " below last line goes to last line - call cursor(9, 1) + eval [9, 1]->cursor() call assert_equal([4, 1, 0, 1], getcurpos()[1:]) " pass string arguments call cursor('3', '3') -- cgit From 245ac6f263b6017c050f885212ee80e5738d3b9f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 12 Sep 2022 17:10:31 +0800 Subject: vim-patch:8.2.5034: there is no way to get the byte index from a virtual column Problem: There is no way to get the byte index from a virtual column. Solution: Add virtcol2col(). (Yegappan Lakshmanan, closes vim/vim#10477, closes vim/vim#10098) https://github.com/vim/vim/commit/5a6ec10cc80ab02eeff644ab19b82312630ea855 Cherry-pick tv_check_for_number_arg() from Vim. Cherry-pick pathshorten() doc change. --- src/nvim/testdir/test_cursor_func.vim | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/nvim/testdir/test_cursor_func.vim') diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim index f13842edc8..2e625f2388 100644 --- a/src/nvim/testdir/test_cursor_func.vim +++ b/src/nvim/testdir/test_cursor_func.vim @@ -373,4 +373,26 @@ func Test_setcursorcharpos() %bw! endfunc +" Test for virtcol2col() +func Test_virtcol2col() + new + call setline(1, ["a\tb\tc"]) + call assert_equal(1, virtcol2col(0, 1, 1)) + call assert_equal(2, virtcol2col(0, 1, 2)) + call assert_equal(2, virtcol2col(0, 1, 8)) + call assert_equal(3, virtcol2col(0, 1, 9)) + call assert_equal(4, virtcol2col(0, 1, 10)) + call assert_equal(4, virtcol2col(0, 1, 16)) + call assert_equal(5, virtcol2col(0, 1, 17)) + call assert_equal(-1, virtcol2col(10, 1, 1)) + call assert_equal(-1, virtcol2col(0, 10, 1)) + call assert_equal(-1, virtcol2col(0, -1, 1)) + call assert_equal(-1, virtcol2col(0, 1, -1)) + call assert_equal(5, virtcol2col(0, 1, 20)) + call assert_fails('echo virtcol2col("0", 1, 20)', 'E1210:') + call assert_fails('echo virtcol2col(0, "1", 20)', 'E1210:') + call assert_fails('echo virtcol2col(0, 1, "1")', 'E1210:') + bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 9c272b75ecf955afe7feedc209f5d9a3b7116650 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 10 Oct 2022 21:11:12 +0800 Subject: vim-patch:8.2.2184: Vim9: no error when using "2" for a line number Problem: Vim9: no error when using "2" for a line number. Solution: Give an error message if the line number is invalid. (closes vim/vim#7492) https://github.com/vim/vim/commit/9a963377b4811e4e0419ec8825856ff4b01331ac N/A patches for version.c: vim-patch:8.2.1465: Vim9: subscript not handled properly Problem: Vim9: subscript not handled properly. Solution: Adjust error message. Remove dead code. Disallow string to number conversion in scripts. https://github.com/vim/vim/commit/56acb0943ede35cd9d2f6667cde2442819ccbf59 --- src/nvim/testdir/test_cursor_func.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir/test_cursor_func.vim') diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim index 2e625f2388..e428bf3e23 100644 --- a/src/nvim/testdir/test_cursor_func.vim +++ b/src/nvim/testdir/test_cursor_func.vim @@ -32,7 +32,7 @@ func Test_move_cursor() call cursor(1, 1, 1) call assert_equal([1, 1, 1], getcurpos()[1:3]) - call assert_equal(-1, cursor(-1, -1)) + call assert_fails('call cursor(-1, -1)', 'E475:') quit! endfunc -- cgit From 249cb8345d6e2f9986ad1dfe42d9cde0f9ed7d6a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 10 Oct 2022 21:38:24 +0800 Subject: vim-patch:9.0.0712: wrong column when calling setcursorcharpos() with zero lnum Problem: Wrong column when calling setcursorcharpos() with zero lnum. Solution: Set the line number before calling buf_charidx_to_byteidx(). (closes vim/vim#11329) https://github.com/vim/vim/commit/79f234499b6692cc16970b7455bc9b002242632f --- src/nvim/testdir/test_cursor_func.vim | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/nvim/testdir/test_cursor_func.vim') diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim index e428bf3e23..9801a45915 100644 --- a/src/nvim/testdir/test_cursor_func.vim +++ b/src/nvim/testdir/test_cursor_func.vim @@ -353,8 +353,14 @@ func Test_setcursorcharpos() normal G call setcursorcharpos([1, 1]) call assert_equal([1, 1], [line('.'), col('.')]) + call setcursorcharpos([2, 7, 0]) call assert_equal([2, 9], [line('.'), col('.')]) + call setcursorcharpos([0, 7, 0]) + call assert_equal([2, 9], [line('.'), col('.')]) + call setcursorcharpos(0, 7, 0) + call assert_equal([2, 9], [line('.'), col('.')]) + call setcursorcharpos(3, 4) call assert_equal([3, 1], [line('.'), col('.')]) call setcursorcharpos([3, 1]) -- cgit From 849394e4e26f487586761a3640475c27ceca30b9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 13 Nov 2022 08:29:05 +0800 Subject: vim-patch:9.0.0863: col() and charcol() only work for the current window (#21038) Problem: col() and charcol() only work for the current window. Solution: Add an optional winid argument. (Yegappan Lakshmanan, closes vim/vim#11466, closes vim/vim#11461) https://github.com/vim/vim/commit/4c8d2f02b3ce037bbe1d5ee12887e343c6bde88f Cherry-pick test_functions.vim change from patch 8.2.0633. Co-authored-by: Yegappan Lakshmanan --- src/nvim/testdir/test_cursor_func.vim | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir/test_cursor_func.vim') diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim index 9801a45915..7f9e74e94b 100644 --- a/src/nvim/testdir/test_cursor_func.vim +++ b/src/nvim/testdir/test_cursor_func.vim @@ -241,8 +241,9 @@ endfunc " Test for the charcol() function func Test_charcol() - call assert_fails('call charcol({})', 'E731:') - call assert_equal(0, charcol(0)) + call assert_fails('call charcol({})', 'E1222:') + call assert_fails('call charcol(".", [])', 'E1210:') + call assert_fails('call charcol(0)', 'E1222:') new call setline(1, ['', "01\tà4è678", 'Ⅵ', '012345678']) @@ -298,6 +299,25 @@ func Test_charcol() call assert_equal([1, 10, 2, 10, 7], g:InsertCurrentCol) iunmap + " Test for getting the column number in another window. + let winid = win_getid() + new + call win_execute(winid, 'normal 1G') + call assert_equal(1, charcol('.', winid)) + call assert_equal(1, charcol('$', winid)) + call win_execute(winid, 'normal 2G6l') + call assert_equal(7, charcol('.', winid)) + call assert_equal(10, charcol('$', winid)) + + " calling from another tab page also works + tabnew + call assert_equal(7, charcol('.', winid)) + call assert_equal(10, charcol('$', winid)) + tabclose + + " unknown window ID + call assert_equal(0, charcol('.', 10001)) + %bw! endfunc -- cgit From 11d2704274ff817678e29f115ba1f074a52e519c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 6 Dec 2022 06:51:17 +0800 Subject: vim-patch:8.2.3193: screenpos() is wrong when 'display' is "lastline" Problem: screenpos() is wrong when the last line is partially visible and 'display' is "lastline". Solution: Also compute the position for a partially visible line. (closes vim/vim#8599) https://github.com/vim/vim/commit/189663bdac1156237c49925f77bd197c1bdea12c Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_cursor_func.vim | 40 ++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'src/nvim/testdir/test_cursor_func.vim') diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim index 7f9e74e94b..0a88bf9db3 100644 --- a/src/nvim/testdir/test_cursor_func.vim +++ b/src/nvim/testdir/test_cursor_func.vim @@ -82,25 +82,41 @@ func Test_screenpos() let winid = win_getid() let [winrow, wincol] = win_screenpos(winid) call assert_equal({'row': winrow, - \ 'col': wincol + 0, - \ 'curscol': wincol + 7, - \ 'endcol': wincol + 7}, winid->screenpos(1, 1)) + \ 'col': wincol + 0, + \ 'curscol': wincol + 7, + \ 'endcol': wincol + 7}, winid->screenpos(1, 1)) call assert_equal({'row': winrow, - \ 'col': wincol + 13, - \ 'curscol': wincol + 13, - \ 'endcol': wincol + 13}, winid->screenpos(1, 7)) + \ 'col': wincol + 13, + \ 'curscol': wincol + 13, + \ 'endcol': wincol + 13}, winid->screenpos(1, 7)) call assert_equal({'row': winrow + 2, - \ 'col': wincol + 1, - \ 'curscol': wincol + 1, - \ 'endcol': wincol + 1}, screenpos(winid, 2, 22)) + \ 'col': wincol + 1, + \ 'curscol': wincol + 1, + \ 'endcol': wincol + 1}, screenpos(winid, 2, 22)) setlocal number call assert_equal({'row': winrow + 3, - \ 'col': wincol + 9, - \ 'curscol': wincol + 9, - \ 'endcol': wincol + 9}, screenpos(winid, 2, 22)) + \ 'col': wincol + 9, + \ 'curscol': wincol + 9, + \ 'endcol': wincol + 9}, screenpos(winid, 2, 22)) + + let wininfo = getwininfo(winid)[0] + call setline(3, ['x']->repeat(wininfo.height)) + call setline(line('$') + 1, 'x'->repeat(wininfo.width * 3)) + setlocal nonumber display=lastline so=0 + exe "normal G\\" + redraw + call assert_equal({'row': winrow + wininfo.height - 1, + \ 'col': wincol + 7, + \ 'curscol': wincol + 7, + \ 'endcol': wincol + 7}, winid->screenpos(line('$'), 8)) + call assert_equal({'row': winrow - 1, 'col': 0, 'curscol': 0, 'endcol': 0}, + \ winid->screenpos(line('$'), 22)) + close call assert_equal({}, screenpos(999, 1, 1)) + bwipe! + set display& call assert_equal({'col': 1, 'row': 1, 'endcol': 1, 'curscol': 1}, screenpos(win_getid(), 1, 1)) " nmenu WinBar.TEST : -- cgit From 6f9cda0f0a9d2e38654e4a0afc4701a356efb862 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 6 Dec 2022 07:26:41 +0800 Subject: vim-patch:8.2.4204: screenpos() has non-zero row for invisible text Problem: screenpos() has non-zero row for invisible text. Solution: Only add the window row when the text is visible. (closes vim/vim#9618) https://github.com/vim/vim/commit/7924a17791217d50be5a91989a9641bf68e7a735 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_cursor_func.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/testdir/test_cursor_func.vim') diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim index 0a88bf9db3..b08eb328b7 100644 --- a/src/nvim/testdir/test_cursor_func.vim +++ b/src/nvim/testdir/test_cursor_func.vim @@ -109,7 +109,7 @@ func Test_screenpos() \ 'col': wincol + 7, \ 'curscol': wincol + 7, \ 'endcol': wincol + 7}, winid->screenpos(line('$'), 8)) - call assert_equal({'row': winrow - 1, 'col': 0, 'curscol': 0, 'endcol': 0}, + call assert_equal({'row': 0, 'col': 0, 'curscol': 0, 'endcol': 0}, \ winid->screenpos(line('$'), 22)) close -- cgit From 10af0549df7ac4ea9907b34624228755b9752318 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 6 Dec 2022 07:41:33 +0800 Subject: vim-patch:8.2.4389: screenpos() does not handle a position in a closed fold Problem: screenpos() does not handle a position in a closed fold. Solution: Check if the position is inside a closed fold. (closes vim/vim#9778) https://github.com/vim/vim/commit/4556a2e8681c5c98fb4c7ca0a016924a69b4452a Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_cursor_func.vim | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir/test_cursor_func.vim') diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim index b08eb328b7..ad78adfc09 100644 --- a/src/nvim/testdir/test_cursor_func.vim +++ b/src/nvim/testdir/test_cursor_func.vim @@ -1,7 +1,10 @@ " Tests for cursor() and other functions that get/set the cursor position +source check.vim + func Test_wrong_arguments() call assert_fails('call cursor(1. 3)', 'E474:') + call assert_fails('call cursor(v:_null_list)', 'E474:') endfunc func Test_move_cursor() @@ -118,14 +121,29 @@ func Test_screenpos() bwipe! set display& - call assert_equal({'col': 1, 'row': 1, 'endcol': 1, 'curscol': 1}, screenpos(win_getid(), 1, 1)) + call assert_equal(#{col: 1, row: 1, endcol: 1, curscol: 1}, screenpos(win_getid(), 1, 1)) " nmenu WinBar.TEST : setlocal winbar=TEST - call assert_equal({'col': 1, 'row': 2, 'endcol': 1, 'curscol': 1}, screenpos(win_getid(), 1, 1)) + call assert_equal(#{col: 1, row: 2, endcol: 1, curscol: 1}, screenpos(win_getid(), 1, 1)) " nunmenu WinBar.TEST setlocal winbar& endfunc +func Test_screenpos_fold() + CheckFeature folding + + enew! + call setline(1, range(10)) + 3,5fold + redraw + call assert_equal(2, screenpos(1, 2, 1).row) + call assert_equal(#{col: 1, row: 3, endcol: 1, curscol: 1}, screenpos(1, 3, 1)) + call assert_equal(3, screenpos(1, 4, 1).row) + call assert_equal(3, screenpos(1, 5, 1).row) + call assert_equal(4, screenpos(1, 6, 1).row) + bwipe! +endfunc + func Test_screenpos_number() rightbelow new rightbelow 73vsplit -- cgit From 0909d987fe925483dc513ae330179339899cd0a5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 6 Dec 2022 07:52:00 +0800 Subject: vim-patch:9.0.1011: ml_get error when using screenpos() Problem: ml_get error when using screenpos(). Solution: Give an error for the line number. (closes vim/vim#11661) https://github.com/vim/vim/commit/99d19438cabaf13074229d9a32e3a4af9ce98744 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_cursor_func.vim | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/testdir/test_cursor_func.vim') diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim index ad78adfc09..634b27b0ed 100644 --- a/src/nvim/testdir/test_cursor_func.vim +++ b/src/nvim/testdir/test_cursor_func.vim @@ -155,6 +155,9 @@ func Test_screenpos_number() let pos = screenpos(winid, 1, 66) call assert_equal(winrow, pos.row) call assert_equal(wincol + 66 + 3, pos.col) + + call assert_fails('echo screenpos(0, 2, 1)', 'E966:') + close bwipe! endfunc -- cgit From 52b3e8bdef6896b53d3c4ee3fbc7d8ae5f480948 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 6 Dec 2022 08:00:30 +0800 Subject: vim-patch:9.0.1016: screenpos() does not count filler lines for diff mode Problem: screenpos() does not count filler lines for diff mode. Solution: Add filler lines. (closes 11658) https://github.com/vim/vim/commit/1cb16c3a20a9d17df1a8dc3813ef64dc98e42637 Co-authored-by: Bram Moolenaar --- src/nvim/testdir/test_cursor_func.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/nvim/testdir/test_cursor_func.vim') diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim index 634b27b0ed..2151076cb9 100644 --- a/src/nvim/testdir/test_cursor_func.vim +++ b/src/nvim/testdir/test_cursor_func.vim @@ -144,6 +144,22 @@ func Test_screenpos_fold() bwipe! endfunc +func Test_screenpos_diff() + CheckFeature diff + + enew! + call setline(1, ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i']) + vnew + call setline(1, ['a', 'b', 'c', 'g', 'h', 'i']) + windo diffthis + wincmd w + call assert_equal(#{col: 3, row: 7, endcol: 3, curscol: 3}, screenpos(0, 4, 1)) + + windo diffoff + bwipe! + bwipe! +endfunc + func Test_screenpos_number() rightbelow new rightbelow 73vsplit -- cgit From 6b3ae24a70a15d485c6aadf059d3fa773f0da4cf Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 18 Dec 2022 21:26:17 +0800 Subject: vim-patch:9.0.1072: screenpos() column result in fold may be too small (#21465) Problem: screenpos() column result in fold may be too small. Solution: Add space of 'number', sign column, etc. (closes vim/vim#11715) https://github.com/vim/vim/commit/ba2d19193201277397c25c1f5a134ea042542555 --- src/nvim/testdir/test_cursor_func.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir/test_cursor_func.vim') diff --git a/src/nvim/testdir/test_cursor_func.vim b/src/nvim/testdir/test_cursor_func.vim index 2151076cb9..bb8e7cd5c5 100644 --- a/src/nvim/testdir/test_cursor_func.vim +++ b/src/nvim/testdir/test_cursor_func.vim @@ -138,8 +138,12 @@ func Test_screenpos_fold() redraw call assert_equal(2, screenpos(1, 2, 1).row) call assert_equal(#{col: 1, row: 3, endcol: 1, curscol: 1}, screenpos(1, 3, 1)) - call assert_equal(3, screenpos(1, 4, 1).row) - call assert_equal(3, screenpos(1, 5, 1).row) + call assert_equal(#{col: 1, row: 3, endcol: 1, curscol: 1}, screenpos(1, 4, 1)) + call assert_equal(#{col: 1, row: 3, endcol: 1, curscol: 1}, screenpos(1, 5, 1)) + setlocal number + call assert_equal(#{col: 5, row: 3, endcol: 5, curscol: 5}, screenpos(1, 3, 1)) + call assert_equal(#{col: 5, row: 3, endcol: 5, curscol: 5}, screenpos(1, 4, 1)) + call assert_equal(#{col: 5, row: 3, endcol: 5, curscol: 5}, screenpos(1, 5, 1)) call assert_equal(4, screenpos(1, 6, 1).row) bwipe! endfunc -- cgit