annotate src/testdir/test_balloon.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 ba5ca7c7d44c
children ad79859e2780
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16594
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Tests for 'balloonevalterm'.
17089
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
2 " A few tests only work in the terminal.
16594
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3
17089
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
4 source check.vim
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17282
diff changeset
5 CheckNotGui
17089
8e9e9124c7a2 patch 8.1.1544: some balloon tests don't run when they can
Bram Moolenaar <Bram@vim.org>
parents: 16965
diff changeset
6 CheckFeature balloon_eval_term
16594
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 source screendump.vim
17657
0da9bc55c31a patch 8.1.1826: tests use hand coded feature and option checks
Bram Moolenaar <Bram@vim.org>
parents: 17282
diff changeset
9 CheckScreendump
16594
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10
17172
6990c1160ea5 patch 8.1.1585: :let-heredoc does not trim enough
Bram Moolenaar <Bram@vim.org>
parents: 17089
diff changeset
11 let s:common_script =<< trim [CODE]
16720
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
12 call setline(1, ["one one one", "two tXo two", "three three three"])
27303
9e0ac05f579a patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
13 set balloonevalterm balloonexpr=MyBalloonExpr()..s:trailing balloondelay=100
9e0ac05f579a patch 8.2.4180: 'balloonexpr' is evaluated in the current script context
Bram Moolenaar <Bram@vim.org>
parents: 21765
diff changeset
14 let s:trailing = '<' " check that script context is set
16720
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
15 func MyBalloonExpr()
18560
81272918c0ea patch 8.1.2274: newlines in 'balloonexpr' result only work in the GUI
Bram Moolenaar <Bram@vim.org>
parents: 17657
diff changeset
16 return "line " .. v:beval_lnum .. " column " .. v:beval_col .. ":\n" .. v:beval_text
16720
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
17 endfun
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
18 redraw
9c90cf08cfa8 patch 8.1.1362: code and data in tests can be hard to read
Bram Moolenaar <Bram@vim.org>
parents: 16600
diff changeset
19 [CODE]
16598
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
20
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
21 func Test_balloon_eval_term()
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
22 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
23 " the balloon.
17282
6f1679e1082d patch 8.1.1640: the CursorHold autocommand takes down a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
24 let xtra_lines =<< trim [CODE]
6f1679e1082d patch 8.1.1640: the CursorHold autocommand takes down a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
25 set updatetime=300
6f1679e1082d patch 8.1.1640: the CursorHold autocommand takes down a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
26 au CursorHold * echo 'hold fired'
6f1679e1082d patch 8.1.1640: the CursorHold autocommand takes down a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
27 func Trigger()
6f1679e1082d patch 8.1.1640: the CursorHold autocommand takes down a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
28 call test_setmouse(2, 6)
6f1679e1082d patch 8.1.1640: the CursorHold autocommand takes down a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
29 call feedkeys("\<MouseMove>\<Ignore>", "xt")
6f1679e1082d patch 8.1.1640: the CursorHold autocommand takes down a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
30 endfunc
6f1679e1082d patch 8.1.1640: the CursorHold autocommand takes down a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
31 [CODE]
30110
ba5ca7c7d44c patch 9.0.0391: using separate delete() call instead of writefile() 'D' flag
Bram Moolenaar <Bram@vim.org>
parents: 27303
diff changeset
32 call writefile(s:common_script + xtra_lines, 'XTest_beval', 'D')
16594
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33
16598
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
34 " Check that the balloon shows up after a mouse move
16594
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 let buf = RunVimInTerminal('-S XTest_beval', {'rows': 10, 'cols': 50})
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 18560
diff changeset
36 call TermWait(buf, 50)
17282
6f1679e1082d patch 8.1.1640: the CursorHold autocommand takes down a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
37 call term_sendkeys(buf, 'll')
6f1679e1082d patch 8.1.1640: the CursorHold autocommand takes down a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
38 call term_sendkeys(buf, ":call Trigger()\<CR>")
16594
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 call VerifyScreenDump(buf, 'Test_balloon_eval_term_01', {})
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40
17282
6f1679e1082d patch 8.1.1640: the CursorHold autocommand takes down a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
41 " Make sure the balloon still shows after 'updatetime' passed and CursorHold
6f1679e1082d patch 8.1.1640: the CursorHold autocommand takes down a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
42 " was triggered.
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 18560
diff changeset
43 call TermWait(buf, 150)
17282
6f1679e1082d patch 8.1.1640: the CursorHold autocommand takes down a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
44 call VerifyScreenDump(buf, 'Test_balloon_eval_term_01a', {})
6f1679e1082d patch 8.1.1640: the CursorHold autocommand takes down a balloon
Bram Moolenaar <Bram@vim.org>
parents: 17172
diff changeset
45
16594
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 " clean up
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47 call StopVimInTerminal(buf)
6f52e82d9d4e patch 8.1.1300: in a terminal 'ballooneval' does not work right away
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 endfunc
16598
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
49
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
50 func Test_balloon_eval_term_visual()
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
51 " Use <Ignore> after <MouseMove> to return from vgetc() without removing
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
52 " the balloon.
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
53 call writefile(s:common_script + [
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
54 \ 'call test_setmouse(3, 6)',
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
55 \ 'call feedkeys("3Gevfr\<MouseMove>\<Ignore>", "xt")',
30110
ba5ca7c7d44c patch 9.0.0391: using separate delete() call instead of writefile() 'D' flag
Bram Moolenaar <Bram@vim.org>
parents: 27303
diff changeset
56 \ ], 'XTest_beval_visual', 'D')
16598
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
57
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
58 " Check that the balloon shows up after a mouse move
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
59 let buf = RunVimInTerminal('-S XTest_beval_visual', {'rows': 10, 'cols': 50})
19954
c087099e9163 patch 8.2.0533: tests using term_wait() can still be flaky
Bram Moolenaar <Bram@vim.org>
parents: 18560
diff changeset
60 call TermWait(buf, 50)
16598
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
61 call VerifyScreenDump(buf, 'Test_balloon_eval_term_02', {})
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
62
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
63 " clean up
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
64 call StopVimInTerminal(buf)
fd0d29d63b85 patch 8.1.1302: v:beval_text is not tested in Visual mode
Bram Moolenaar <Bram@vim.org>
parents: 16594
diff changeset
65 endfunc
21765
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
66
08940efa6b4e patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents: 19954
diff changeset
67 " vim: shiftwidth=2 sts=2 expandtab