Mercurial > vim
annotate src/testdir/test_cursor_func.vim @ 27096:d539c144aeb4 v8.2.4077
patch 8.2.4077: not all Libsensors files are recognized
Commit: https://github.com/vim/vim/commit/8d9e470aa91a93da7d6bda62521aef69a79e956d
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 13 14:49:10 2022 +0000
patch 8.2.4077: not all Libsensors files are recognized
Problem: Not all Libsensors files are recognized.
Solution: Add "sensors.d/*" pattern. (Doug Kearns)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 13 Jan 2022 16:00:05 +0100 |
parents | fb67cd7d30a7 |
children | 2bec1976362c |
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 |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 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
|
4 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
|
5 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
|
6 endfunc |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 func Test_move_cursor() |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 new |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 call setline(1, ['aaa', 'bbb', 'ccc', 'ddd']) |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 call cursor([1, 1, 0, 1]) |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 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
|
14 call cursor([4, 3, 0, 3]) |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 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
|
16 |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 call cursor(2, 2) |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
18 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
|
19 " line number zero keeps the line number |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 call cursor(0, 1) |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
21 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
|
22 " col number zero keeps the column |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 call cursor(3, 0) |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
24 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
|
25 " 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
|
26 eval [9, 1]->cursor() |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
27 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
|
28 " 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
|
29 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
|
30 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
|
31 |
16668
81be817c9d9a
patch 8.1.1336: some eval functionality is not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
15492
diff
changeset
|
32 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
|
33 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
|
34 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
|
35 |
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
|
36 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
|
37 |
7590
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 quit! |
4d9814f9fc39
commit https://github.com/vim/vim/commit/5a46a58eb6e50cb5204909cc2202e3400761263f
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 endfunc |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
40 |
26881
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
41 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
|
42 new |
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
43 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
|
44 |
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
45 " 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
|
46 normal! 1G$ |
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
47 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
|
48 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
|
49 |
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
50 quit! |
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
51 endfunc |
fb67cd7d30a7
patch 8.2.3969: value of MAXCOL not available in Vim script
Bram Moolenaar <Bram@vim.org>
parents:
25312
diff
changeset
|
52 |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
53 " 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
|
54 function s:Highlight_Matching_Pair() |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
55 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
|
56 eval save_cursor->setpos('.') |
8011
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
57 endfunc |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
58 |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
59 func Test_curswant_with_autocommand() |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
60 new |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
61 call setline(1, ['func()', '{', '}', '----']) |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
62 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
|
63 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
|
64 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
|
65 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
|
66 call assert_equal('-X---', getline(4)) |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
67 autocmd! CursorMovedI * |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
68 quit! |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
69 endfunc |
26f555e9aab1
commit https://github.com/vim/vim/commit/2ab375e54ef4eac438d1aef8b99d9e71f2fa0c63
Christian Brabandt <cb@256bit.org>
parents:
7590
diff
changeset
|
70 |
15492
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
71 " 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
|
72 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
|
73 new |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
74 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
|
75 exe "normal! ggf6j" |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
76 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
|
77 set cursorcolumn |
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 quit! |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
80 endfunc |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
81 |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
82 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
|
83 new |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
84 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
|
85 exe "normal! ggf6j" |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
86 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
|
87 set cursorline |
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 quit! |
126cdab63a83
patch 8.1.0754: preferred column is lost when setting 'cursorcolumn'
Bram Moolenaar <Bram@vim.org>
parents:
11183
diff
changeset
|
90 endfunc |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
91 |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
92 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
|
93 rightbelow new |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
94 rightbelow 20vsplit |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
95 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
|
96 redraw |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
97 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
|
98 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
|
99 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
|
100 \ '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
|
101 \ '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
|
102 \ '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
|
103 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
|
104 \ '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
|
105 \ '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
|
106 \ '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
|
107 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
|
108 \ '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
|
109 \ '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
|
110 \ '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
|
111 setlocal number |
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
112 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
|
113 \ '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
|
114 \ '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
|
115 \ '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
|
116 |
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
117 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
|
118 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
|
119 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
|
120 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
|
121 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
|
122 redraw |
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
123 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
|
124 \ 'col': wincol + 7, |
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
125 \ 'curscol': wincol + 7, |
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
126 \ 'endcol': wincol + 7}, winid->screenpos(line('$'), 8)) |
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
127 call assert_equal({'row': winrow - 1, 'col': 0, 'curscol': 0, 'endcol': 0}, |
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
128 \ 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
|
129 |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
130 close |
20978
2c3e7a6bd6c6
patch 8.2.1040: not enough testing for movement commands
Bram Moolenaar <Bram@vim.org>
parents:
20158
diff
changeset
|
131 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
|
132 |
17292
8a095d343c59
patch 8.1.1645: cannot use a popup window for a balloon
Bram Moolenaar <Bram@vim.org>
parents:
16668
diff
changeset
|
133 bwipe! |
25312
7a254d0705e2
patch 8.2.3193: screenpos() is wrong when 'display' is "lastline"
Bram Moolenaar <Bram@vim.org>
parents:
23642
diff
changeset
|
134 set display& |
23213
477f1b4c6826
patch 8.2.2152: screenpos() does not include the WinBar offset
Bram Moolenaar <Bram@vim.org>
parents:
20978
diff
changeset
|
135 |
477f1b4c6826
patch 8.2.2152: screenpos() does not include the WinBar offset
Bram Moolenaar <Bram@vim.org>
parents:
20978
diff
changeset
|
136 call assert_equal({'col': 1, 'row': 1, 'endcol': 1, 'curscol': 1}, screenpos(win_getid(), 1, 1)) |
477f1b4c6826
patch 8.2.2152: screenpos() does not include the WinBar offset
Bram Moolenaar <Bram@vim.org>
parents:
20978
diff
changeset
|
137 nmenu WinBar.TEST : |
477f1b4c6826
patch 8.2.2152: screenpos() does not include the WinBar offset
Bram Moolenaar <Bram@vim.org>
parents:
20978
diff
changeset
|
138 call assert_equal({'col': 1, 'row': 2, 'endcol': 1, 'curscol': 1}, screenpos(win_getid(), 1, 1)) |
477f1b4c6826
patch 8.2.2152: screenpos() does not include the WinBar offset
Bram Moolenaar <Bram@vim.org>
parents:
20978
diff
changeset
|
139 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
|
140 endfunc |
18469
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
141 |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
142 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
|
143 rightbelow new |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
144 rightbelow 73vsplit |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
145 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
|
146 setlocal number |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
147 redraw |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
148 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
|
149 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
|
150 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
|
151 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
|
152 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
|
153 close |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
154 bwipe! |
66964658cc3c
patch 8.1.2228: screenpos() returns wrong values when 'number' is set
Bram Moolenaar <Bram@vim.org>
parents:
18035
diff
changeset
|
155 endfunc |
20109
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
18469
diff
changeset
|
156 |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
157 " 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
|
158 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
|
159 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
|
160 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
|
161 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
|
162 |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
163 " 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
|
164 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
|
165 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
|
166 return '' |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
167 endfunc |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
168 |
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
|
169 " 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
|
170 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
|
171 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
|
172 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
|
173 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
|
174 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
|
175 |
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 " 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
|
177 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
|
178 call assert_equal([0, 1, 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
|
179 call assert_equal([0, 4, 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
|
180 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
|
181 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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 |
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 " 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
|
188 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
|
189 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
|
190 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
|
191 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
|
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 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
|
194 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
|
195 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
|
196 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
|
197 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
|
198 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
|
199 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
|
200 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
|
201 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
|
202 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
|
203 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
|
204 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
|
205 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
|
206 |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
207 " 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
|
208 " 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
|
209 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
|
210 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
|
211 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
|
212 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
|
213 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
|
214 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
|
215 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
|
216 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
|
217 \ [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
|
218 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
|
219 |
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
|
220 %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
|
221 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
|
222 |
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 " 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
|
224 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
|
225 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
|
226 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
|
227 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
|
228 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
|
229 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
|
230 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
|
231 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
|
232 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
|
233 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
|
234 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
|
235 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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 |
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
|
241 " 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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 " 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
|
247 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
|
248 enew! |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
249 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
|
250 |
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 %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
|
252 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
|
253 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
|
254 |
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 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
|
256 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
|
257 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
|
258 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
|
259 |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
260 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
|
261 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
|
262 return '' |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
263 endfunc |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
264 |
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
|
265 " 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
|
266 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
|
267 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
|
268 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
|
269 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
|
270 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
|
271 |
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
|
272 " 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
|
273 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
|
274 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
|
275 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
|
276 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
|
277 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
|
278 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
|
279 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
|
280 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
|
281 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
|
282 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
|
283 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
|
284 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
|
285 |
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
|
286 " 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
|
287 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
|
288 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
|
289 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
|
290 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
|
291 |
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 " 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
|
293 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
|
294 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
|
295 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
|
296 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
|
297 |
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 " 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
|
299 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
|
300 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
|
301 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
|
302 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
|
303 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
|
304 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
|
305 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
|
306 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
|
307 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
|
308 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
|
309 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
|
310 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
|
311 |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
312 " 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
|
313 " 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
|
314 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
|
315 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
|
316 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
|
317 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
|
318 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
|
319 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
|
320 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
|
321 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
|
322 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
|
323 |
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
|
324 %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
|
325 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
|
326 |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
327 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
|
328 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
|
329 return '' |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
330 endfunc |
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
331 |
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
|
332 " 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
|
333 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
|
334 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
|
335 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
|
336 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
|
337 |
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
|
338 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
|
339 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
|
340 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
|
341 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
|
342 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
|
343 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
|
344 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
|
345 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
|
346 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
|
347 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
|
348 |
23600
f4347a61ed38
patch 8.2.2342: "char" functions may return wrong column in Insert mode
Bram Moolenaar <Bram@vim.org>
parents:
23563
diff
changeset
|
349 " 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
|
350 " 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
|
351 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
|
352 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
|
353 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
|
354 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
|
355 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
|
356 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
|
357 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
|
358 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
|
359 \ [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
|
360 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
|
361 |
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
|
362 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
|
363 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
|
364 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
|
365 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
|
366 %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
|
367 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
|
368 |
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 " 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
|
370 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
|
371 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
|
372 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
|
373 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
|
374 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
|
375 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
|
376 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
|
377 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
|
378 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
|
379 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
|
380 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
|
381 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
|
382 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
|
383 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
|
384 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
|
385 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
|
386 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
|
387 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
|
388 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
|
389 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
|
390 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
|
391 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
|
392 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
|
393 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
|
394 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
|
395 |
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 %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
|
397 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
|
398 |
20109
e82996ad131f
patch 8.2.0610: some tests are still old style
Bram Moolenaar <Bram@vim.org>
parents:
18469
diff
changeset
|
399 " vim: shiftwidth=2 sts=2 expandtab |