Mercurial > vim
annotate src/testdir/test_cursor_func.vim @ 30079:105f946422d1 v9.0.0377
patch 9.0.0377: argument assignment does not work
Commit: https://github.com/vim/vim/commit/eb5adf19d15de4dd1d148954ac5345154f0fea60
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Sep 4 13:41:37 2022 +0100
patch 9.0.0377: argument assignment does not work
Problem: Argument assignment does not work.
Solution: Skip over "=".
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 04 Sep 2022 14:45:02 +0200 |
parents | 9f25e0ed831d |
children | b7efd41d43b8 |
rev | line source |
---|---|
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
1 " Tests for cursor() and other functions that get/set the cursor position |
7590
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
27726
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
3 source check.vim |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
4 |
7590
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 func Test_wrong_arguments() |
11183
1c4ebbae41d2
patch 8.0.0478: tests use assert_true(0) and assert_false(1) to report errors
Christian Brabandt <cb@256bit.org>
parents:
11105
diff
changeset
|
6 call assert_fails('call cursor(1. 3)', 'E474:') |
20158
94f05de75e9f
patch 8.2.0634: crash with null partial and blob
Bram Moolenaar <Bram@vim.org>
parents:
20109
diff
changeset
|
7 call assert_fails('call cursor(test_null_list())', 'E474:') |
7590
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 endfunc |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 func Test_move_cursor() |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 new |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 call setline(1, ['aaa', 'bbb', 'ccc', 'ddd']) |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 call cursor([1, 1, 0, 1]) |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 call assert_equal([1, 1, 0, 1], getcurpos()[1:]) |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 call cursor([4, 3, 0, 3]) |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 call assert_equal([4, 3, 0, 3], getcurpos()[1:]) |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 call cursor(2, 2) |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
20 call assert_equal([2, 2, 0, 2], getcurpos()[1:]) |
7590
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 " line number zero keeps the line number |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 call cursor(0, 1) |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
23 call assert_equal([2, 1, 0, 1], getcurpos()[1:]) |
7590
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 " col number zero keeps the column |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 call cursor(3, 0) |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
26 call assert_equal([3, 1, 0, 1], getcurpos()[1:]) |
7590
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 " below last line goes to last line |
17837
f71ee7b04f0b
patch 8.1.1915: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17292
diff
changeset
|
28 eval [9, 1]->cursor() |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
29 call assert_equal([4, 1, 0, 1], getcurpos()[1:]) |
23642
8df4e9e2394f
patch 8.2.2363: curpos() does not accept a string argument as before
Bram Moolenaar <Bram@vim.org>
parents:
23600
diff
changeset
|
30 " pass string arguments |
8df4e9e2394f
patch 8.2.2363: curpos() does not accept a string argument as before
Bram Moolenaar <Bram@vim.org>
parents:
23600
diff
changeset
|
31 call cursor('3', '3') |
8df4e9e2394f
patch 8.2.2363: curpos() does not accept a string argument as before
Bram Moolenaar <Bram@vim.org>
parents:
23600
diff
changeset
|
32 call assert_equal([3, 3, 0, 3], getcurpos()[1:]) |
7590
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 |
16668
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
15492
diff
changeset
|
34 call setline(1, ["\<TAB>"]) |
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
15492
diff
changeset
|
35 call cursor(1, 1, 1) |
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
15492
diff
changeset
|
36 call assert_equal([1, 1, 1], getcurpos()[1:3]) |
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
15492
diff
changeset
|
37 |
23276
b79cdad3ea2e
patch 8.2.2184: Vim9: no error when using "2" for a line number
Bram Moolenaar <Bram@vim.org>
parents:
23213
diff
changeset
|
38 call assert_fails('call cursor(-1, -1)', 'E475:') |
16668
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
15492
diff
changeset
|
39 |
7590
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 quit! |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 endfunc |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
42 |
26881
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
43 func Test_curswant_maxcol() |
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
44 new |
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
45 call setline(1, 'foo') |
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
46 |
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
47 " Test that after "$" command curswant is set to the same value as v:maxcol. |
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
48 normal! 1G$ |
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
49 call assert_equal(v:maxcol, getcurpos()[4]) |
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
50 call assert_equal(v:maxcol, winsaveview().curswant) |
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
51 |
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
52 quit! |
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
53 endfunc |
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
54 |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
55 " Very short version of what matchparen does. |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
56 function s:Highlight_Matching_Pair() |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
57 let save_cursor = getcurpos() |
18000
7a19c8d6bb9e
patch 8.1.1996: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17994
diff
changeset
|
58 eval save_cursor->setpos('.') |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
59 endfunc |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
60 |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
61 func Test_curswant_with_autocommand() |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
62 new |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
63 call setline(1, ['func()', '{', '}', '----']) |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
64 autocmd! CursorMovedI * call s:Highlight_Matching_Pair() |
11105
7c7e496e625d
patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents:
9121
diff
changeset
|
65 call test_override("char_avail", 1) |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
66 exe "normal! 3Ga\<Down>X\<Esc>" |
11105
7c7e496e625d
patch 8.0.0440: not enough test coverage in Insert mode
Christian Brabandt <cb@256bit.org>
parents:
9121
diff
changeset
|
67 call test_override("char_avail", 0) |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
68 call assert_equal('-X---', getline(4)) |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
69 autocmd! CursorMovedI * |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
70 quit! |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
71 endfunc |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
72 |
15492
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
73 " Tests for behavior of curswant with cursorcolumn/line |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
74 func Test_curswant_with_cursorcolumn() |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
75 new |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
76 call setline(1, ['01234567', '']) |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
77 exe "normal! ggf6j" |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
78 call assert_equal(6, winsaveview().curswant) |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
79 set cursorcolumn |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
80 call assert_equal(6, winsaveview().curswant) |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
81 quit! |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
82 endfunc |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
83 |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
84 func Test_curswant_with_cursorline() |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
85 new |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
86 call setline(1, ['01234567', '']) |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
87 exe "normal! ggf6j" |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
88 call assert_equal(6, winsaveview().curswant) |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
89 set cursorline |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
90 call assert_equal(6, winsaveview().curswant) |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
91 quit! |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
92 endfunc |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
93 |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
94 func Test_screenpos() |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
95 rightbelow new |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
96 rightbelow 20vsplit |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
97 call setline(1, ["\tsome text", "long wrapping line here", "next line"]) |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
98 redraw |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
99 let winid = win_getid() |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
100 let [winrow, wincol] = win_screenpos(winid) |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
101 call assert_equal({'row': winrow, |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
102 \ 'col': wincol + 0, |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
103 \ 'curscol': wincol + 7, |
18035
11dca9732a48
patch 8.1.2013: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
18000
diff
changeset
|
104 \ 'endcol': wincol + 7}, winid->screenpos(1, 1)) |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
105 call assert_equal({'row': winrow, |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
106 \ 'col': wincol + 13, |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
107 \ 'curscol': wincol + 13, |
17994
0dcc2ee838dd
patch 8.1.1993: more functions can be used as methods
Bram Moolenaar <Bram@vim.org>
parents:
17837
diff
changeset
|
108 \ 'endcol': wincol + 13}, winid->screenpos(1, 7)) |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
109 call assert_equal({'row': winrow + 2, |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
110 \ 'col': wincol + 1, |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
111 \ 'curscol': wincol + 1, |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
112 \ 'endcol': wincol + 1}, screenpos(winid, 2, 22)) |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
113 setlocal number |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
114 call assert_equal({'row': winrow + 3, |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
115 \ 'col': wincol + 9, |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
116 \ 'curscol': wincol + 9, |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
117 \ 'endcol': wincol + 9}, screenpos(winid, 2, 22)) |
25312
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
118 |
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
119 let wininfo = getwininfo(winid)[0] |
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
120 call setline(3, ['x']->repeat(wininfo.height)) |
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
121 call setline(line('$') + 1, 'x'->repeat(wininfo.width * 3)) |
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
122 setlocal nonumber display=lastline so=0 |
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
123 exe "normal G\<C-Y>\<C-Y>" |
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
124 redraw |
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
125 call assert_equal({'row': winrow + wininfo.height - 1, |
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
126 \ 'col': wincol + 7, |
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
127 \ 'curscol': wincol + 7, |
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
128 \ 'endcol': wincol + 7}, winid->screenpos(line('$'), 8)) |
27352
2bec1976362c
patch 8.2.4204: screenpos() has non-zero row for invisible text
Bram Moolenaar <Bram@vim.org>
parents:
26881
diff
changeset
|
129 call assert_equal({'row': 0, 'col': 0, 'curscol': 0, 'endcol': 0}, |
25312
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
130 \ winid->screenpos(line('$'), 22)) |
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
131 |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
132 close |
20978
2c3e7a6bd6c6
patch 8.2.1040: not enough testing for movement commands
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
133 call assert_equal({}, screenpos(999, 1, 1)) |
25312
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
134 |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
135 bwipe! |
25312
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
136 set display& |
23213
477f1b4c6826
patch 8.2.2152: screenpos() does not include the WinBar offset
Bram Moolenaar <Bram@vim.org>
parents:
20978
diff
changeset
|
137 |
27726
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
138 call assert_equal(#{col: 1, row: 1, endcol: 1, curscol: 1}, screenpos(win_getid(), 1, 1)) |
23213
477f1b4c6826
patch 8.2.2152: screenpos() does not include the WinBar offset
Bram Moolenaar <Bram@vim.org>
parents:
20978
diff
changeset
|
139 nmenu WinBar.TEST : |
27726
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
140 call assert_equal(#{col: 1, row: 2, endcol: 1, curscol: 1}, screenpos(win_getid(), 1, 1)) |
23213
477f1b4c6826
patch 8.2.2152: screenpos() does not include the WinBar offset
Bram Moolenaar <Bram@vim.org>
parents:
20978
diff
changeset
|
141 nunmenu WinBar.TEST |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
142 endfunc |
18469
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
143 |
27726
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
144 func Test_screenpos_fold() |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
145 CheckFeature folding |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
146 |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
147 enew! |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
148 call setline(1, range(10)) |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
149 3,5fold |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
150 redraw |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
151 call assert_equal(2, screenpos(1, 2, 1).row) |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
152 call assert_equal(#{col: 1, row: 3, endcol: 1, curscol: 1}, screenpos(1, 3, 1)) |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
153 call assert_equal(3, screenpos(1, 4, 1).row) |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
154 call assert_equal(3, screenpos(1, 5, 1).row) |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
155 call assert_equal(4, screenpos(1, 6, 1).row) |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
156 bwipe! |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
157 endfunc |
d3ed8b1a7bde
patch 8.2.4389: screenpos() does not handle a position in a closed fold
Bram Moolenaar <Bram@vim.org>
parents:
27352
diff
changeset
|
158 |
18469
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
159 func Test_screenpos_number() |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
160 rightbelow new |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
161 rightbelow 73vsplit |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
162 call setline (1, repeat('x', 66)) |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
163 setlocal number |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
164 redraw |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
165 let winid = win_getid() |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
166 let [winrow, wincol] = win_screenpos(winid) |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
167 let pos = screenpos(winid, 1, 66) |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
168 call assert_equal(winrow, pos.row) |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
169 call assert_equal(wincol + 66 + 3, pos.col) |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
170 close |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
171 bwipe! |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
172 endfunc |
20109
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
18469
diff
changeset
|
173 |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
174 " Save the visual start character position |
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
175 func SaveVisualStartCharPos() |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
176 call add(g:VisualStartPos, getcharpos('v')) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
177 return '' |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
178 endfunc |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
179 |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
180 " Save the current cursor character position in insert mode |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
181 func SaveInsertCurrentCharPos() |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
182 call add(g:InsertCurrentPos, getcharpos('.')) |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
183 return '' |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
184 endfunc |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
185 |
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
186 " Test for the getcharpos() function |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
187 func Test_getcharpos() |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
188 call assert_fails('call getcharpos({})', 'E731:') |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
189 call assert_equal([0, 0, 0, 0], getcharpos(0)) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
190 new |
28419
6e501ecd1bb7
patch 8.2.4734: getcharpos() may change a mark position
Bram Moolenaar <Bram@vim.org>
parents:
27726
diff
changeset
|
191 call setline(1, ['', "01\tà4è678", 'Ⅵ', '012345678', ' │ x']) |
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
192 |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
193 " Test for '.' and '$' |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
194 normal 1G |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
195 call assert_equal([0, 1, 1, 0], getcharpos('.')) |
28419
6e501ecd1bb7
patch 8.2.4734: getcharpos() may change a mark position
Bram Moolenaar <Bram@vim.org>
parents:
27726
diff
changeset
|
196 call assert_equal([0, 5, 1, 0], getcharpos('$')) |
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
197 normal 2G6l |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
198 call assert_equal([0, 2, 7, 0], getcharpos('.')) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
199 normal 3G$ |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
200 call assert_equal([0, 3, 1, 0], getcharpos('.')) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
201 normal 4G$ |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
202 call assert_equal([0, 4, 9, 0], getcharpos('.')) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
203 |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
204 " Test for a mark |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
205 normal 2G7lmmgg |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
206 call assert_equal([0, 2, 8, 0], getcharpos("'m")) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
207 delmarks m |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
208 call assert_equal([0, 0, 0, 0], getcharpos("'m")) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
209 |
28419
6e501ecd1bb7
patch 8.2.4734: getcharpos() may change a mark position
Bram Moolenaar <Bram@vim.org>
parents:
27726
diff
changeset
|
210 " Check mark does not move |
6e501ecd1bb7
patch 8.2.4734: getcharpos() may change a mark position
Bram Moolenaar <Bram@vim.org>
parents:
27726
diff
changeset
|
211 normal 5Gfxma |
6e501ecd1bb7
patch 8.2.4734: getcharpos() may change a mark position
Bram Moolenaar <Bram@vim.org>
parents:
27726
diff
changeset
|
212 call assert_equal([0, 5, 5, 0], getcharpos("'a")) |
6e501ecd1bb7
patch 8.2.4734: getcharpos() may change a mark position
Bram Moolenaar <Bram@vim.org>
parents:
27726
diff
changeset
|
213 call assert_equal([0, 5, 5, 0], getcharpos("'a")) |
6e501ecd1bb7
patch 8.2.4734: getcharpos() may change a mark position
Bram Moolenaar <Bram@vim.org>
parents:
27726
diff
changeset
|
214 call assert_equal([0, 5, 5, 0], getcharpos("'a")) |
6e501ecd1bb7
patch 8.2.4734: getcharpos() may change a mark position
Bram Moolenaar <Bram@vim.org>
parents:
27726
diff
changeset
|
215 |
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
216 " Test for the visual start column |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
217 vnoremap <expr> <F3> SaveVisualStartCharPos() |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
218 let g:VisualStartPos = [] |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
219 exe "normal 2G6lv$\<F3>ohh\<F3>o\<F3>" |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
220 call assert_equal([[0, 2, 7, 0], [0, 2, 10, 0], [0, 2, 5, 0]], g:VisualStartPos) |
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
221 call assert_equal([0, 2, 9, 0], getcharpos('v')) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
222 let g:VisualStartPos = [] |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
223 exe "normal 3Gv$\<F3>o\<F3>" |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
224 call assert_equal([[0, 3, 1, 0], [0, 3, 2, 0]], g:VisualStartPos) |
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
225 let g:VisualStartPos = [] |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
226 exe "normal 1Gv$\<F3>o\<F3>" |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
227 call assert_equal([[0, 1, 1, 0], [0, 1, 1, 0]], g:VisualStartPos) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
228 vunmap <F3> |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
229 |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
230 " Test for getting the position in insert mode with the cursor after the |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
231 " last character in a line |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
232 inoremap <expr> <F3> SaveInsertCurrentCharPos() |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
233 let g:InsertCurrentPos = [] |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
234 exe "normal 1GA\<F3>" |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
235 exe "normal 2GA\<F3>" |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
236 exe "normal 3GA\<F3>" |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
237 exe "normal 4GA\<F3>" |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
238 exe "normal 2G6li\<F3>" |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
239 call assert_equal([[0, 1, 1, 0], [0, 2, 10, 0], [0, 3, 2, 0], [0, 4, 10, 0], |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
240 \ [0, 2, 7, 0]], g:InsertCurrentPos) |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
241 iunmap <F3> |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
242 |
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
243 %bw! |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
244 endfunc |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
245 |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
246 " Test for the setcharpos() function |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
247 func Test_setcharpos() |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
248 call assert_equal(-1, setcharpos('.', test_null_list())) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
249 new |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
250 call setline(1, ['', "01\tà4è678", 'Ⅵ', '012345678']) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
251 call setcharpos('.', [0, 1, 1, 0]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
252 call assert_equal([1, 1], [line('.'), col('.')]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
253 call setcharpos('.', [0, 2, 7, 0]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
254 call assert_equal([2, 9], [line('.'), col('.')]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
255 call setcharpos('.', [0, 3, 4, 0]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
256 call assert_equal([3, 1], [line('.'), col('.')]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
257 call setcharpos('.', [0, 3, 1, 0]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
258 call assert_equal([3, 1], [line('.'), col('.')]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
259 call setcharpos('.', [0, 4, 0, 0]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
260 call assert_equal([4, 1], [line('.'), col('.')]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
261 call setcharpos('.', [0, 4, 20, 0]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
262 call assert_equal([4, 9], [line('.'), col('.')]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
263 |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
264 " Test for mark |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
265 delmarks m |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
266 call setcharpos("'m", [0, 2, 9, 0]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
267 normal `m |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
268 call assert_equal([2, 11], [line('.'), col('.')]) |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
269 " unload the buffer and try to set the mark |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
270 let bnr = bufnr() |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
271 enew! |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
272 call assert_equal(-1, setcharpos("'m", [bnr, 2, 2, 0])) |
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
273 |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
274 %bw! |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
275 call assert_equal(-1, setcharpos('.', [10, 3, 1, 0])) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
276 endfunc |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
277 |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
278 func SaveVisualStartCharCol() |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
279 call add(g:VisualStartCol, charcol('v')) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
280 return '' |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
281 endfunc |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
282 |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
283 func SaveInsertCurrentCharCol() |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
284 call add(g:InsertCurrentCol, charcol('.')) |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
285 return '' |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
286 endfunc |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
287 |
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
288 " Test for the charcol() function |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
289 func Test_charcol() |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
290 call assert_fails('call charcol({})', 'E731:') |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
291 call assert_equal(0, charcol(0)) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
292 new |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
293 call setline(1, ['', "01\tà4è678", 'Ⅵ', '012345678']) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
294 |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
295 " Test for '.' and '$' |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
296 normal 1G |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
297 call assert_equal(1, charcol('.')) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
298 call assert_equal(1, charcol('$')) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
299 normal 2G6l |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
300 call assert_equal(7, charcol('.')) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
301 call assert_equal(10, charcol('$')) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
302 normal 3G$ |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
303 call assert_equal(1, charcol('.')) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
304 call assert_equal(2, charcol('$')) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
305 normal 4G$ |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
306 call assert_equal(9, charcol('.')) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
307 call assert_equal(10, charcol('$')) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
308 |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
309 " Test for [lnum, '$'] |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
310 call assert_equal(1, charcol([1, '$'])) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
311 call assert_equal(10, charcol([2, '$'])) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
312 call assert_equal(2, charcol([3, '$'])) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
313 call assert_equal(0, charcol([5, '$'])) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
314 |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
315 " Test for a mark |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
316 normal 2G7lmmgg |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
317 call assert_equal(8, charcol("'m")) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
318 delmarks m |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
319 call assert_equal(0, charcol("'m")) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
320 |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
321 " Test for the visual start column |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
322 vnoremap <expr> <F3> SaveVisualStartCharCol() |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
323 let g:VisualStartCol = [] |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
324 exe "normal 2G6lv$\<F3>ohh\<F3>o\<F3>" |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
325 call assert_equal([7, 10, 5], g:VisualStartCol) |
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
326 call assert_equal(9, charcol('v')) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
327 let g:VisualStartCol = [] |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
328 exe "normal 3Gv$\<F3>o\<F3>" |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
329 call assert_equal([1, 2], g:VisualStartCol) |
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
330 let g:VisualStartCol = [] |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
331 exe "normal 1Gv$\<F3>o\<F3>" |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
332 call assert_equal([1, 1], g:VisualStartCol) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
333 vunmap <F3> |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
334 |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
335 " Test for getting the column number in insert mode with the cursor after |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
336 " the last character in a line |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
337 inoremap <expr> <F3> SaveInsertCurrentCharCol() |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
338 let g:InsertCurrentCol = [] |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
339 exe "normal 1GA\<F3>" |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
340 exe "normal 2GA\<F3>" |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
341 exe "normal 3GA\<F3>" |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
342 exe "normal 4GA\<F3>" |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
343 exe "normal 2G6li\<F3>" |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
344 call assert_equal([1, 10, 2, 10, 7], g:InsertCurrentCol) |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
345 iunmap <F3> |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
346 |
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
347 %bw! |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
348 endfunc |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
349 |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
350 func SaveInsertCursorCharPos() |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
351 call add(g:InsertCursorPos, getcursorcharpos('.')) |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
352 return '' |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
353 endfunc |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
354 |
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
355 " Test for getcursorcharpos() |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
356 func Test_getcursorcharpos() |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
357 call assert_equal(getcursorcharpos(), getcursorcharpos(0)) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
358 call assert_equal([0, 0, 0, 0, 0], getcursorcharpos(-1)) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
359 call assert_equal([0, 0, 0, 0, 0], getcursorcharpos(1999)) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
360 |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
361 new |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
362 call setline(1, ['', "01\tà4è678", 'Ⅵ', '012345678']) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
363 normal 1G9l |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
364 call assert_equal([0, 1, 1, 0, 1], getcursorcharpos()) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
365 normal 2G9l |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
366 call assert_equal([0, 2, 9, 0, 14], getcursorcharpos()) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
367 normal 3G9l |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
368 call assert_equal([0, 3, 1, 0, 1], getcursorcharpos()) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
369 normal 4G9l |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
370 call assert_equal([0, 4, 9, 0, 9], getcursorcharpos()) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
371 |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
372 " Test for getting the cursor position in insert mode with the cursor after |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
373 " the last character in a line |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
374 inoremap <expr> <F3> SaveInsertCursorCharPos() |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
375 let g:InsertCursorPos = [] |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
376 exe "normal 1GA\<F3>" |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
377 exe "normal 2GA\<F3>" |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
378 exe "normal 3GA\<F3>" |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
379 exe "normal 4GA\<F3>" |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
380 exe "normal 2G6li\<F3>" |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
381 call assert_equal([[0, 1, 1, 0, 1], [0, 2, 10, 0, 15], [0, 3, 2, 0, 2], |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
382 \ [0, 4, 10, 0, 10], [0, 2, 7, 0, 12]], g:InsertCursorPos) |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
383 iunmap <F3> |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
384 |
23563
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
385 let winid = win_getid() |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
386 normal 2G5l |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
387 wincmd w |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
388 call assert_equal([0, 2, 6, 0, 11], getcursorcharpos(winid)) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
389 %bw! |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
390 endfunc |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
391 |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
392 " Test for setcursorcharpos() |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
393 func Test_setcursorcharpos() |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
394 call assert_fails('call setcursorcharpos(test_null_list())', 'E474:') |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
395 call assert_fails('call setcursorcharpos([1])', 'E474:') |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
396 call assert_fails('call setcursorcharpos([1, 1, 1, 1, 1])', 'E474:') |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
397 new |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
398 call setline(1, ['', "01\tà4è678", 'Ⅵ', '012345678']) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
399 normal G |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
400 call setcursorcharpos([1, 1]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
401 call assert_equal([1, 1], [line('.'), col('.')]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
402 call setcursorcharpos([2, 7, 0]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
403 call assert_equal([2, 9], [line('.'), col('.')]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
404 call setcursorcharpos(3, 4) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
405 call assert_equal([3, 1], [line('.'), col('.')]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
406 call setcursorcharpos([3, 1]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
407 call assert_equal([3, 1], [line('.'), col('.')]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
408 call setcursorcharpos([4, 0, 0, 0]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
409 call assert_equal([4, 1], [line('.'), col('.')]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
410 call setcursorcharpos([4, 20]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
411 call assert_equal([4, 9], [line('.'), col('.')]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
412 normal 1G |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
413 call setcursorcharpos([100, 100, 100, 100]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
414 call assert_equal([4, 9], [line('.'), col('.')]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
415 normal 1G |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
416 call setcursorcharpos('$', 1) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
417 call assert_equal([4, 1], [line('.'), col('.')]) |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
418 |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
419 %bw! |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
420 endfunc |
87671ccc6c6b
patch 8.2.2324: not easy to get mark en cursor posotion by character count
Bram Moolenaar <Bram@vim.org>
parents:
23276
diff
changeset
|
421 |
29024
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
422 " Test for virtcol2col() |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
423 func Test_virtcol2col() |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
424 new |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
425 call setline(1, ["a\tb\tc"]) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
426 call assert_equal(1, virtcol2col(0, 1, 1)) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
427 call assert_equal(2, virtcol2col(0, 1, 2)) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
428 call assert_equal(2, virtcol2col(0, 1, 8)) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
429 call assert_equal(3, virtcol2col(0, 1, 9)) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
430 call assert_equal(4, virtcol2col(0, 1, 10)) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
431 call assert_equal(4, virtcol2col(0, 1, 16)) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
432 call assert_equal(5, virtcol2col(0, 1, 17)) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
433 call assert_equal(-1, virtcol2col(10, 1, 1)) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
434 call assert_equal(-1, virtcol2col(0, 10, 1)) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
435 call assert_equal(-1, virtcol2col(0, -1, 1)) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
436 call assert_equal(-1, virtcol2col(0, 1, -1)) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
437 call assert_equal(5, virtcol2col(0, 1, 20)) |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
438 call assert_fails('echo virtcol2col("0", 1, 20)', 'E1210:') |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
439 call assert_fails('echo virtcol2col(0, "1", 20)', 'E1210:') |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
440 call assert_fails('echo virtcol2col(0, 1, "1")', 'E1210:') |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
441 bw! |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
442 endfunc |
9f25e0ed831d
patch 8.2.5034: there is no way to get the byte index from a virtual column
Bram Moolenaar <Bram@vim.org>
parents:
28419
diff
changeset
|
443 |
20109
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
18469
diff
changeset
|
444 " vim: shiftwidth=2 sts=2 expandtab |