Mercurial > vim
annotate src/testdir/test_set.vim @ 34379:37b4c89ba420 v9.1.0116
patch 9.1.0116: win_split_ins may not check available room
Commit: https://github.com/vim/vim/commit/0fd44a5ad81ade342cb54d8984965bdedd2272c8
Author: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Date: Tue Feb 20 20:28:15 2024 +0100
patch 9.1.0116: win_split_ins may not check available room
Problem: win_split_ins has no check for E36 when moving an existing
window
Solution: check for room and fix the issues in f_win_splitmove()
(Sean Dewar)
win_split_ins has no check for E36 when moving an existing window,
allowing for layouts with many overlapping zero-sized windows to be
created (which may also cause drawing issues with tablines and such).
f_win_splitmove also has some bugs.
So check for room and fix the issues in f_win_splitmove. Handle failure
in the two relevant win_split_ins callers by restoring the original
layout, and factor the common logic into win_splitmove.
Don't check for room when opening an autocommand window, as it's a
temporary window that's rarely interacted with or drawn anyhow, and is
rather important for some autocommands.
Issues fixed in f_win_splitmove:
- Error if splitting is disallowed.
- Fix heap-use-after-frees if autocommands fired from switching to "targetwin"
close "wp" or "oldwin".
- Fix splitting the wrong window if autocommands fired from switching to
"targetwin" switch to a different window.
- Ensure -1 is returned for all errors.
Also handle allocation failure a bit earlier in make_snapshot (callers,
except win_splitmove, don't really care if a snapshot can't be made, so
just ignore the return value).
Note: Test_smoothscroll_in_zero_width_window failed after these changes with
E36, as it was using the previous behaviour to create a zero-width window.
I've fixed the test such that it fails with UBSAN as expected when v9.0.1367 is
reverted (and simplified it too).
related: #14042
Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 20 Feb 2024 22:30:04 +0100 |
parents | 9a7fb0665f9f |
children |
rev | line source |
---|---|
7426
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Tests for the :set command |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
3 source check.vim |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
4 |
7426
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 function Test_set_backslash() |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 let isk_save = &isk |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 set isk=a,b,c |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 set isk+=d |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 call assert_equal('a,b,c,d', &isk) |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 set isk+=\\,e |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 call assert_equal('a,b,c,d,\,e', &isk) |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 set isk-=e |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 call assert_equal('a,b,c,d,\', &isk) |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 set isk-=\\ |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 call assert_equal('a,b,c,d', &isk) |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 let &isk = isk_save |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 endfunction |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 function Test_set_add() |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 let wig_save = &wig |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 set wildignore=*.png, |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 set wildignore+=*.jpg |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 call assert_equal('*.png,*.jpg', &wig) |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 let &wig = wig_save |
779a7c14c795
commit https://github.com/vim/vim/commit/8f79acdf7ede2693fbda53c3c9693f16db4f193b
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 endfunction |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
7426
diff
changeset
|
30 |
25238
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
31 |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
32 " :set, :setlocal, :setglobal without arguments show values of options. |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
33 func Test_set_no_arg() |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
34 set textwidth=79 |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
35 let a = execute('set') |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
36 call assert_match("^\n--- Options ---\n.*textwidth=79\\>", a) |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
37 set textwidth& |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
38 |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
39 setlocal textwidth=78 |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
40 let a = execute('setlocal') |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
41 call assert_match("^\n--- Local option values ---\n.*textwidth=78\\>", a) |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
42 setlocal textwidth& |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
43 |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
44 setglobal textwidth=77 |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
45 let a = execute('setglobal') |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
46 call assert_match("^\n--- Global option values ---\n.*textwidth=77\\>", a) |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
47 setglobal textwidth& |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
48 endfunc |
dd98794f7d8c
patch 8.2.3155: some option related code not covered by tests
Bram Moolenaar <Bram@vim.org>
parents:
21765
diff
changeset
|
49 |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
50 func Test_set_termcap() |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
51 CheckNotGui |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
52 |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
53 let lines = split(execute('set termcap'), "\n") |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
54 call assert_match('--- Terminal codes ---', lines[0]) |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
55 " four columns |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
56 call assert_match('t_..=.*t_..=.*t_..=.*t_..=', lines[1]) |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
57 |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
58 for keys_idx in range(len(lines)) |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
59 if lines[keys_idx] =~ '--- Terminal keys ---' |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
60 break |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
61 endif |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
62 endfor |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
63 call assert_true(keys_idx < len(lines)) |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
64 " three columns |
26402
9a7fb0665f9f
patch 8.2.3732: "set! termcap" test fails
Bram Moolenaar <Bram@vim.org>
parents:
26400
diff
changeset
|
65 call assert_match('<[^>]*> .*<[^>]*> .*<[^>]*> ', lines[keys_idx + 1]) |
26400
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
66 |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
67 let more_lines = split(execute('set! termcap'), "\n") |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
68 for i in range(len(more_lines)) |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
69 if more_lines[i] =~ '--- Terminal keys ---' |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
70 break |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
71 endif |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
72 endfor |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
73 call assert_true(i < len(more_lines)) |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
74 call assert_true(i > keys_idx) |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
75 call assert_true(len(more_lines) - i > len(lines) - keys_idx) |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
76 endfunc |
d26bab4f6aca
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys
Bram Moolenaar <Bram@vim.org>
parents:
25238
diff
changeset
|
77 |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
7426
diff
changeset
|
78 " vim: shiftwidth=2 sts=2 expandtab |