summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_window_cmd.vim
AgeCommit message (Collapse)Author
2024-03-13patch 9.1.0175: wrong window positions with 'winfix{width,height}'v9.1.0175Sean Dewar
Problem: winframe functions incorrectly recompute window positions if the altframe wasn't adjacent to the closed frame, which is possible if adjacent windows had 'winfix{width,height}' set. Solution: recompute for windows within the parent of the altframe and closed frame. Skip this (as before) if the altframe was top/left, but only if adjacent to the closed frame, as positions won't change in that case. Also correct the return value documentation for win_screenpos. (Sean Dewar) The issue revealed itself after removing the win_comp_pos call below winframe_restore in win_splitmove. Similarly, wrong positions could result from windows closed in other tabpages, as win_free_mem uses winframe_remove (at least until it is entered later, where enter_tabpage calls win_comp_pos). NOTE: As win_comp_pos handles only curtab, it's possible via other means for positions in non-current tabpages to be wrong (e.g: after changing 'laststatus', 'showtabline', etc.). Given enter_tabpage recomputes it, maybe it's intentional as an optimization? Should probably be documented in win_screenpos then, but I won't address that here. closes: #14191 Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-12patch 9.1.0171: Small split-move related improvementsv9.1.0171Sean Dewar
Problem: small improvements can be made to split-move related functions. Solution: apply them (Sean Dewar): - Improve some doc comments (frame_flatten should still work for non-current tabpages, despite the topframe check, which looks benign, though I'm unsure if it's still needed; see #2467). - f_win_splitmove should check_split_disallowed on wp, not targetwin, as that's what win_splitmove checks (though it's probably unnecessary to check b_locked_split at all; see #14109, which I hope to get around to finishing at some point). - Make winframe_restore restore window positions for the altframe, which winframe_remove changes. This doesn't affect the prior behaviour, as we called win_comp_pos after, but as win_comp_pos only works for curtab, and winframe_remove supports non-current tabpages, we should undo it. Regardless, this should mean we don't need win_comp_pos anymore; adjust tests to check that window positions remain unchanged. I'm not sure win_comp_pos is needed after last_status anyway if it doesn't steal rows from another frame to make room for a new statusline, which shouldn't be the case after winframe_remove? To be safe, I'll leave it as is. closes: #14185 Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-03-12patch 9.1.0170: Re-allow curwin == prevwin, but document it insteadv9.1.0170Sean Dewar
Problem: more places exist where curwin == prevwin, and it may even be expected in some cases. Solution: revert v9.1.0001, but document that it's possible instead. (Sean Dewar) I've had a change of heart for the following reasons: - A quick 'n dirty [GitHub code search](https://github.com/search?q=%2F%28winnr%5C%28%5C%29%5Cs*%3D%3D%5Cs*winnr%5C%28%5B%27%22%5D%23%5B%27%22%5D%5C%29%7Cwinnr%5C%28%5B%27%22%5D%23%5B%27%22%5D%5C%29%5Cs*%3D%3D%5Cs*winnr%5C%28%5C%29%29%2F&type=code) reveals some cases where it's expected in the wild. Particularly, it made me aware `winnr() == winnr('#')` is possible when curwin is changed temporarily during the evaluation of a &statusline expression item (`%{...}`), and is used to show something different on the statusline belonging to the previous window; that behaviour wasn't changed in v9.1.0001, but it means curwin == prevwin makes sense in some cases. - The definition and call sites of back_to_prevwin imply some expectation that prevwin == wp (== curwin) is possible, as it's used to skip entering the prevwin in that case. - Prior to v9.1.0001, `:wincmd p` would not beep in the case that was patched in v9.1.0001, but now does. That resulted in #14047 being opened, as it affected the CtrlP plugin. I find it odd that `:wincmd p` had cases where it wouldn't beep despite doing nothing, but it may be preferable to keep things that way (or instead also beep if curwin == prevwin, if that's preferred). - After more digging, I found cases in win_free_mem, enter_tabpage, aucmd_restbuf and qf_open_new_cwindow where curwin == prevwin is possible (many of them from autocommands). Others probably exist too, especially in places where curwin is changed temporarily. fixes: #14047 closes: #14186 Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-24patch 9.1.0130: [security]: UAF if win_split_ins autocommands delete "wp"v9.1.0130Sean Dewar
Problem: heap-use-after-free in win_splitmove if Enter/Leave autocommands from win_split_ins immediately closes "wp". Solution: check that "wp" is valid after win_split_ins. (Sean Dewar) closes: #14078 Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-22patch 9.1.0128: win_gotoid() may abort even when not switching a windowv9.1.0128Sean Dewar
Problem: win_gotoid() checks for textlock and other things when switching to a window that is already current (after v9.1.0119) Solution: return early with success when attempting to switch to curwin (Sean Dewar) Other potential causes of E565 from win_gotoid after v9.1.0119 should be correct. Plugins can consider using win_execute() instead if they wish to temporarily switch windows during textlock. fixes: #14073 closes: #14074 Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-21patch 9.1.0121: Infinite loop or signed overflow with 'smoothscroll'v9.1.0121Sean Dewar
Problem: infinite loop in win_update with 'smoothscroll' set when window width is equal to textoff, or signed integer overflow if smaller. Solution: don't revalidate wp->w_skipcol in that case, as no buffer text is being shown. (Sean Dewar) Don't instead reset w_skipcol; that would lose the scroll position within the line, which may be undesirable if the window is made wider later. Also include changes from the splitmove PR #14042 that I (in my infinite Git wisdom) forgot to commit. This includes a change to Test_window_split_no_room to ensure it doesn't fail for some screen sizes. Move Test_smoothscroll_in_zero_width_window to test_scroll_opt.vim, as that file feels more appropriate. closes: #14068 Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-20patch 9.1.0119: can move away from cmdwin using win_splitmove()v9.1.0119Sean Dewar
Problem: can switch windows while textlocked via f_win_gotoid and f_win_splitmove (which also allows switching in the cmdwin). Solution: Check text_or_buf_locked in f_win_splitmove() (Sean Dewar) While at it, call text_or_buf_locked() in f_win_gotoid() instead of testing for cmdwin_type() (which text_buf_locked() does and in addition will also verify that the buffer is not locked). closes: #14042 Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-20patch 9.1.0117: Stop split-moving from firing WinNew and WinNewPre autocommandsv9.1.0117Sean Dewar
Problem: win_splitmove fires WinNewPre and possibly WinNew when moving windows, even though no new windows are created. Solution: don't fire WinNew and WinNewPre when inserting an existing window, even if it isn't the current window. Improve the accuracy of related documentation. (Sean Dewar) Likewise, before this patch, WinClosed was not fired anyway (even for :wincmd H/J/K/L, which also didn't fire WinNew, but did still fire WinNewPre), despite documentation saying windows are "closed". Note that :wincmd T actually indeed works by creating a new window (and closing the old one), unlike the others. This also fixes issues where WinNewPre is fired when split-moving while curwin doesn't yet have a frame or entry in the window list, causing many things to not work (it's not considered valid at that point). This was guaranteed when using :wincmd H/J/K/L. Because WinNewPre is no longer fired when split-moving, this makes restoring the previous window layout on failure easier, as we can be sure that frames are not resized from WinNewPre autocommands if win_split_ins fails. This allows us to use a different strategy in the following commit. -- In my opinion, this leaves questions about the current usefulness of WinNewPre. A motivation described in #10635 states how creating a new window can steal room from other windows, and how WinNewPre will be useful for detecting that, but this is also true when inserting an existing window, which now doesn't fire it. Maybe the autocommand should be changed to have a better name? There are also other issues I found with the current implementation of WinNewPre that need addressing: - it allows switching windows and tabpages, which can cause incorrect windows to be split/moved, and big problems when switching tabpages. - it fires before win_split_ins checks for room, before it makes any changes to window sizes or before it considers allocating a new window. This should be changed or documented. I hope to address some of this stuff in a different PR, if possible. related: #14038 Signed-off-by: Sean Dewar <6256228+seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-02-20patch 9.1.0116: win_split_ins may not check available roomv9.1.0116Sean Dewar
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>
2024-01-03patch 9.1.0001: when closing window, wincmd p may failv9.1.0001Sean Dewar
Avoid `prevwin == curwin` when closing `curwin` Problem: When closing the current window (or when moving it to a tabpage), the previous window may refer to the new current window (`winnr() == winnr('#')`) if that window is selected as the new current window. Solution: Set `prevwin = NULL` when switching away from an invalid `curwin` and the target window was the `prevwin`. (Sean Dewar) related: #4537 closes: #13762 Signed-off-by: Sean Dewar <seandewar@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
2023-08-20patch 9.0.1772: Cursor may be adjusted in 'splitkeep'ed windowsv9.0.1772Luuk van Baal
Problem: Cursor is adjusted in window that did not change in size by 'splitkeep'. Solution: Only check that cursor position is valid in a window that has changed in size. closes: #12509 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
2023-06-02patch 9.0.1599: Cursor not adjusted when 'splitkeep' is not "cursor"v9.0.1599Luuk van Baal
Problem: Cursor not adjusted when near top or bottom of window and 'splitkeep' is not "cursor". Solution: Move boundary checks to outer cursor move functions, inner functions should only return valid cursor positions. (Luuk van Baal, closes #12480)
2023-05-06patch 9.0.1513: text scrolls unnecessarily when splittingv9.0.1513Luuk van Baal
Problem: Text scrolls unnecessarily when splitting and 'splitkeep' is not "cursor". Solution: Avoid resetting w_skipcol. (Luuk van Baal, closes #12334)
2023-04-26patch 9.0.1491: wrong scrolling with ls=0 and :botright splitv9.0.1491zeertzjq
Problem: Wrong scrolling with ls=0 and :botright split. Solution: Add statusline before calling frame_new_height(). (closes #12299)
2023-03-01patch 9.0.1367: divide by zero in zero-width windowv9.0.1367Bram Moolenaar
Problem: Divide by zero in zero-width window. Solution: Check the width is positive.
2023-02-15patch 9.0.1312: Cursor position wrong when splitting window in insert modev9.0.1312Luuk van Baal
Problem: Cursor position wrong when splitting window in insert mode. Solution: Pass the actual mode to win_fix_cursor(). (Luuk van Baal, closes #11999,
2023-02-14patch 9.0.1310: 'splitkeep' test has failuresv9.0.1310Bram Moolenaar
Problem: 'splitkeep' test has failures. Solution: Adjust expected cursor line position.
2023-01-14patch 9.0.1195: restoring KeyTyped when building statusline not testedv9.0.1195zeertzjq
Problem: Restoring KeyTyped when building statusline not tested. Solution: Add a test. Clean up and fix other tests. (closes #11815)
2022-12-13patch 9.0.1051: after a failed CTRL-W ] next command splits windowv9.0.1051Rob Pilling
Problem: After a failed CTRL-W ] next command splits window. Solution: Reset postponed_split. (Rob Pilling, closes #11698)
2022-12-05patch 9.0.1007: there is no way to get a list of swap file namesv9.0.1007Bram Moolenaar
Problem: There is no way to get a list of swap file names. Solution: Add the swapfilelist() function. Use it in the test script to clean up. Remove deleting individual swap files.
2022-12-04patch 9.0.1005: a failed test may leave a swap file behindv9.0.1005Bram Moolenaar
Problem: A failed test may leave a swap file behind. Solution: Delete the swap file to avoid another test to fail. Use another file name.
2022-11-28patch 9.0.0964: status line not redrawn when 'splitkeep' is "screen"v9.0.0964Luuk van Baal
Problem: Status line of other window not redrawn when dragging it when 'splitkeep' is set to "screen". Solution: Set w_redr_status earlier. (Luuk van Baal, closes #11635, closes #11632)
2022-11-02patch 9.0.0828: various typosv9.0.0828dundargoc
Problem: Various typos. Solution: Correct typos. (closes #11432)
2022-11-01patch 9.0.0824: crash when using win_move_separator() in other tab pagev9.0.0824zeertzjq
Problem: Crash when using win_move_separator() in other tab page. Solution: Check for valid window in current tab page. (closes #11479, closes #11427)
2022-10-31patch 9.0.0820: memory leak with empty shell commandv9.0.0821Bram Moolenaar
Problem: Memory leak with empty shell command. Solution: Free the empty string.
2022-10-15patch 9.0.0769: too many delete() calls in testsv9.0.0769Bram Moolenaar
Problem: Too many delete() calls in tests. Solution: Use deferred delete where possible.
2022-10-05patch 9.0.0667: ml_get error when 'splitkeep' is "screen"v9.0.0667Luuk van Baal
Problem: ml_get error when 'splitkeep' is "screen". (Marius Gedminas) Solution: Check the botline is not too large. (Luuk van Baal, closes #11293, closes #11292)
2022-10-05patch 9.0.0663: tests check for +cmdwin feature which is always presentv9.0.0663zeertzjq
Problem: Tests check for +cmdwin feature which is always present. Solution: Remove the checks. (closes #11287)
2022-10-03patch 9.0.0647: the 'splitscroll' option is not a good namev9.0.0647Luuk van Baal
Problem: The 'splitscroll' option is not a good name. Solution: Rename 'splitscroll' to 'splitkeep' and make it a string option, also supporting "topline". (Luuk van Baal, closes #11258)
2022-09-27patch 9.0.0603: with 'nosplitscroll' folds are not handled correctlyv9.0.0603Luuk van Baal
Problem: With 'nosplitscroll' folds are not handled correctly. Solution: Take care of closed folds when moving the cursor. (Luuk van Baal, closes #11234)
2022-09-23patch 9.0.0555: scrolling with 'nosplitscroll' in callback changing curwinv9.0.0555Luuk van Baal
Problem: Scrolling with 'nosplitscroll' in callback changing curwin. Solution: Invalidate w_cline_row in the right place. (Luuk van Baal, closes #11185)
2022-09-19patch 9.0.0505: various problems with 'nosplitscroll'v9.0.0505Luuk van Baal
Problem: Various problems with 'nosplitscroll'. Solution: Fix 'nosplitscroll' problems. (Luuk van Baal, closes #11166)
2022-09-17patch 9.0.0486: text scrolled with 'nosplitscroll', autocmd win and helpv9.0.0486Luuk van Baal
Problem: Text scrolled with 'nosplitscroll', autocmd win opened and help window closed. Solution: Skip win_fix_scroll() in more situations. (Luuk van Baal, closes #11150)
2022-09-16patch 9.0.0478: test for 'splitscroll' takes too much timev9.0.0478Luuk van Baal
Problem: Test for 'splitscroll' takes too much time. Solution: Only test some of the combinations. (Luuk van Baal, closes #11139)
2022-09-15patch 9.0.0471: no test for what patch 9.0.0469 fixesv9.0.0471mityu
Problem: No test for what patch 9.0.0469 fixes. Solution: Add a test. (closes #11140)
2022-09-14patch 9.0.0465: cursor moves when cmdwin is closed when 'splitscroll' is offv9.0.0465mityu
Problem: Cursor moves when cmdwin is closed when 'splitscroll' is off. Solution: Temporarily set 'splitscroll' when jumping back to the original window. (closes #11128)
2022-09-14patch 9.0.0461: 'scroll' is not always updatedv9.0.0461Luuk van Baal
Problem: 'scroll' is not always updated. Solution: Call win_init_size() at the right place.
2022-09-13patch 9.0.0455: a few problems with 'splitscroll'v9.0.0455Luuk van Baal
Problem: A few problems with 'splitscroll'. Solution: Fix 'splitscroll' problems. (Luuk van Baal, closes #11117)
2022-09-11patch 9.0.0445: when opening/closing window text moves up/downv9.0.0445Luuk van Baal
Problem: When opening/closing window text moves up/down. Solution: Add the 'splitscroll' option. When off text will keep its position as much as possible.
2022-09-07patch 9.0.0403: 'equalalways' may be off when 'laststatus' is zerov9.0.0403Luuk van Baal
Problem: 'equalalways' may be off when 'laststatus' is zero. Solution: call last_status() before win_equal(). (Luuk van Baal, closes #11070)
2022-09-02patch 9.0.0363: common names in test files causes tests to be flakyv9.0.0363Bram Moolenaar
Problem: Common names in test files causes tests to be flaky. Solution: Use more specific names.
2022-08-31patch 9.0.0342: ":wincmd =" equalizes in two directionsv9.0.0342Bram Moolenaar
Problem: ":wincmd =" equalizes in two directions. Solution: Make ":vertical wincmd =" equalize vertically only and ":horizontal wincmd =" equalize horizontally only.
2022-08-31patch 9.0.0340: the 'cmdheight' zero support causes too much troublev9.0.0340Bram Moolenaar
Problem: The 'cmdheight' zero support causes too much trouble. Solution: Revert support for 'cmdheight' being zero.
2022-08-30patch 9.0.0335: checks for Dictionary argument often give a vague errorv9.0.0335Yegappan Lakshmanan
Problem: Checks for Dictionary argument often give a vague error message. Solution: Give a useful error message. (Yegappan Lakshmanan, closes #11009)
2022-08-10patch 9.0.0187: command line height changes when maximizing window heightv9.0.0187Bram Moolenaar
Problem: Command line height changes when maximizing window height. Solution: Do not change the command line height. (closes #10885)
2022-07-30patch 9.0.0114: the command line takes up space even when not usedv9.0.0114Shougo Matsushita
Problem: The command line takes up space even when not used. Solution: Allow for 'cmdheight' to be set to zero. (Shougo Matsushita, closes #10675, closes #940)
2022-04-03patch 8.2.4670: memory allocation failures for new tab page not testedv8.2.4670Yegappan Lakshmanan
Problem: Memory allocation failures for new tab page not tested. Solution: Add tests with failing memory allocation. (Yegappan Lakshmanan, closes #10067)
2022-01-29patch 8.2.4248: no proper test for moving the window separatorv8.2.4248zeertzjq
Problem: No proper test for moving the window separator. Solution: Add a test. Add comment in code. (closes #9656)
2022-01-10patch 8.2.4052: not easy to resize a window from a pluginv8.2.4052Daniel Steinberg
Problem: Not easy to resize a window from a plugin. Solution: Add win_move_separator() and win_move_statusline() functions. (Daniel Steinberg, closes #9486)
2021-12-12patch 8.2.3789: Test_window_minimal_size can fail on a slow machinev8.2.3789ichizok
Problem: Test_window_minimal_size can fail on a slow machine. Solution: Do not rely on timers firing at the expected time. (Ozaki Kiichi, closes #9335)