aboutsummaryrefslogtreecommitdiff
path: root/test
Commit message (Collapse)AuthorAge
...
| * | | fix(api): fix set_lines viewport adjustment, but this time goodbfredl2024-03-14
| |/ / | | | | | | | | | fixes #27720
* / / fix(terminal): disable reflow againChristian Clason2024-03-14
|/ / | | | | | | | | | | | | reverts https://github.com/neovim/neovim/commit/c855eee919f2d4edc9b9fa91b277454290fbabfe This setting introduces constant CI failures on macos (see https://github.com/neovim/neovim/issues/23762).
* | fix(treesitter): highlight injections properlyLewis Russell2024-03-14
| | | | | | | | | | `on_line_impl` doesn't highlight single lines, so using pattern indexes to offset priority doesn't work.
* | vim-patch:9.1.0177: Coverity reports dead codezeertzjq2024-03-14
| | | | | | | | | | | | | | | | | | | | Problem: Coverity reports dead code. Solution: Remove the dead code. Also fix a mistake in ml_get_pos_len() and update some comments (zeertzjq). closes: vim/vim#14189 https://github.com/vim/vim/commit/8c55d60658b7ee3458dca57fc5eec90ca9bb9bf3
* | vim-patch:9.1.0176: Cursor column wrong with 'virtualedit' and concealzeertzjq2024-03-14
| | | | | | | | | | | | | | | | | | | | Problem: Cursor column wrong with 'virtualedit' and conceal. Solution: Correct cursor column at end of line if never reached. (zeertzjq) closes: vim/vim#14190 https://github.com/vim/vim/commit/253ff4dece4e6cc4a9ff3ed935bc78f832b6fb7c
* | vim-patch:9.1.0174: 'cursorline' and 'wincolor' hl missing with conceal and wrapzeertzjq2024-03-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: 'cursorline' and 'wincolor' highlight missing with concealed and wrapped lines. Solution: Apply 'cursorline' and 'wincolor' highlight to boguscols. (zeertzjq) Since 'cursorline' and 'wincolor' highlight apply after the end of the line, it is more consistent to have them also apply to boguscols. Assigning MAXCOL to values in ScreenCols[] make mouse click behave the same with 'cursorline' and 'nocursorline', but such behavior may be incorrect, as it puts the cursor on the next screen line. That may be fixed in a future PR. closes: vim/vim#14192 https://github.com/vim/vim/commit/21b0a3df8c4abb884489dfcc0c92b1bbe058f291
* | vim-patch:9.1.0178: E1513 might be confusing (#27846)zeertzjq2024-03-14
| | | | | | | | | | | | | | | | | | | | | | | | Problem: E1513 might be confusing (Christoph Thoma) Solution: reword error message, fix test to not depend on the actual message fixes: vim/vim#14189 https://github.com/vim/vim/commit/0a32b8854b52381fd17a6fcc5e38a3b9e77c8923 Co-authored-by: Christian Brabandt <cb@256bit.org>
* | vim-patch:9.1.0175: wrong window positions with 'winfix{width,height}' (#27845)Sean Dewar2024-03-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: vim/vim#14191 Nvim: don't reuse "wp" for "topleft" in winframe_remove, so the change integrates better with the call to winframe_find_altwin before it. https://github.com/vim/vim/commit/5866bc3a0f54115d5982fdc09bdbe4c45069265a
* | fix(api/buffer): fix handling of viewport of non-current bufferbfredl2024-03-13
| | | | | | | | | | | | | | | | | | | | | | A lot of functions in move.c only worked for curwin, alternatively took a `wp` arg but still only work if that happens to be curwin. Refactor those that are needed for update_topline(wp) to work for any window. fixes #27723 fixes #27720
* | fix(drawline): initialize linebuf_attr to 0 instead of -1 (#27840)zeertzjq2024-03-13
| | | | | | This also obviates the end-of-line loop when there is virtual text.
* | vim-patch:9.1.0171: Small split-move related improvementsSean Dewar2024-03-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: small improvements can be made to split-move related functions. Solution: apply them (Sean Dewar): Some of these changes were already applied to Nvim. Here are the ones which were missing: - 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 vim/vim#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 vim/vim#14109, which I hope to get around to finishing at some point). - Apply the winframe_restore comment changes, and remove win_comp_pos from after winframe_restore in win_splitmove, as it shouldn't be necessary (no need to remove it from nvim_win_set_config too, as it was already omitted). Move win_append after winframe_restore in win_splitmove to match Vim. closes: vim/vim#14185 https://github.com/vim/vim/commit/5cac1a9bee0798d70a7fd80363a1f697759638e8
* | vim-patch:9.1.0170: Re-allow curwin == prevwin, but document it insteadSean Dewar2024-03-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 vim/vim#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: vim/vim#14047 closes: vim/vim#14186 https://github.com/vim/vim/commit/d64801e913314d2e19dbb38f60e6d285238debff
* | vim-patch:9.1.0169: current window number returned by tabpagewinnr may be ↵Sean Dewar2024-03-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | outdated Problem: current window number returned by tabpagewinnr may be outdated when called from win_execute for the original tabpage. Solution: update the original tabpage's tp_curwin in switch_win; use {un}use_tabpage instead. Don't do it in restore_win to ensure tp_curwin of the temporarily visited tabpage is unchanged from switch_win visiting it, as before. (Sean Dewar) Maybe restore_win should only restore tp_curwin if `curtab == switchwin->sw_curtab`, in case the user changed tabpages from within win_execute, but not doing that is consistent with the old behaviour. related: vim/vim#14186 https://github.com/vim/vim/commit/e101028a5c896480c61fef7ea16855255925709b
* | feat(treesitter): support URLs (#27132)Gregory Anders2024-03-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tree-sitter queries can add URLs to a capture using the `#set!` directive, e.g. (inline_link (link_text) @text.reference (link_destination) @text.uri (#set! @text.reference "url" @text.uri)) The pattern above is included by default in the `markdown_inline` highlight query so that users with supporting terminals will see hyperlinks. For now, this creates a hyperlink for *all* Markdown URLs of the pattern [link text](link url), even if `link url` does not contain a valid protocol (e.g. if `link url` is a path to a file). We may wish to change this in the future to only linkify when the URL has a valid protocol scheme, but for now we delegate handling this to the terminal emulator. In order to support directives which reference other nodes, the highlighter must be updated to use `iter_matches` rather than `iter_captures`. The former provides the `match` table which maps capture IDs to nodes. However, this has its own challenges: - `iter_matches` does not guarantee the order in which patterns are iterated matches the order in the query file. So we must enforce ordering manually using "subpriorities" (#27131). The pattern index of each match dictates the extmark's subpriority. - When injections are used, the highlighter contains multiple trees. The pattern indices of each tree must be offset relative to the maximum pattern index from all previous trees to ensure that extmarks appear in the correct order. - The `iter_captures` implementation currently has a bug where the "match" table is only returned for the first capture within a pattern (see #27274). This bug means that `#set!` directives in a query apply only to the first capture within a pattern. Unfortunately, many queries in the wild have come to depend on this behavior. `iter_matches` does not share this flaw, so switching to `iter_matches` exposed bugs in existing highlight queries. These queries have been updated in this repo, but may still need to be updated by users. The `#set!` directive applies to the _entire_ query pattern when used without a capture argument. To make `#set!` apply only to a single capture, the capture must be given as an argument.
* | vim-patch:9.1.0167: Changing buffer in another window causes it to show ↵zeertzjq2024-03-12
| | | | | | | | | | | | | | | | | | | | | | | | matchparen (#27820) Problem: Changing buffer in another window using win_execute() causes it to show matchparen (after 9.0.0969). Solution: Delay highlighting with SafeState in BufWinEnter. (zeertzjq) closes: vim/vim#14177 https://github.com/vim/vim/commit/49ffb6b428e1e053446ec0209558a8f9d0963ae7
* | vim-patch:9.1.0166: Internal error with blockwise getregion() in another ↵zeertzjq2024-03-12
| | | | | | | | | | | | | | | | | | | | buffer (#27819) Problem: Internal error with blockwise getregion() in another buffer Solution: Also change curwin->w_buffer when changing curbuf (zeertzjq) closes: vim/vim#14179 https://github.com/vim/vim/commit/5406eb8722bddb6a04876956f9a53c1752994851
* | vim-patch:8.2.4944: text properties are wrong after "cc" (#27821)zeertzjq2024-03-12
| | | | | | | | | | | | | | | | | | Problem: Text properties are wrong after "cc". (Axel Forsman) Solution: Pass the deleted byte count to inserted_bytes(). (closes vim/vim#10412, closes vim/vim#7737, closes vim/vim#5763) https://github.com/vim/vim/commit/d0b1a09f44654bb5e29b09de1311845200f17d90 Co-authored-by: LemonBoy <thatlemon@gmail.com>
* | Merge pull request #27812 from luukvbaal/cmdheightbfredl2024-03-11
|\ \ | | | | | | feat(ui): allow non-zero 'cmdheight' with ext_messages
| * | feat(ui): allow non-zero 'cmdheight' with ext_messagesLuuk van Baal2024-03-11
| | | | | | | | | | | | | | | | | | | | | Problem: Arbitrary restriction on 'cmdheight' with ext_messages. The 'cmdheight'-area may be desirable for the replacing cmdline. Solution: Allow non-zero 'cmdheight' with ext_messages.
* | | test: correct order of arguments to eq() (#27816)zeertzjq2024-03-11
|/ /
* | vim-patch:9.1.0156: Make 'wfb' failing to split still report E1513zeertzjq2024-03-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: may not be clear why failing to split causes an ":Xdo" command to abort if 'wfb' is set. Solution: do not return immediately if win_split fails, so E1513 is still given. Expect both errors in the test. Also fix tests to pass CI. (Sean Dewar) closes: vim/vim#14152 https://github.com/vim/vim/commit/769eb2d0c3614f9ea6fffa82329558f1a4af384f Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
* | vim-patch:9.1.0152: Coverity complains about ignoring return valuezeertzjq2024-03-11
| | | | | | | | | | | | | | | | | | | | Problem: Coverity complains about ignoring return value of win_split() (after v9.1.150) Solution: Check if win_split() failed, add winfixbuf.res to Makefile https://github.com/vim/vim/commit/af7ae8160041e2d17c56945381e9370e7178e596 Co-authored-by: Christian Brabandt <cb@256bit.org>
* | vim-patch:9.1.0150: Several minor 'winfixbuf' issuesColin Kennedy2024-03-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: several minor 'winfixbuf' issues exist, mostly relating to the quickfix list Solution: address them and adjust tests. Retab and reflow a few things too. (Sean Dewar) Things touched include: - Replace the semsgs with gettext'd emsgs. - Handle window switching in ex_listdo properly, so curbuf and curwin are kept in-sync and trigger autocommands; handle those properly. - Don't change the list entry index in qf_jump_edit_buffer if we fail due to 'wfb' (achieved by returning FAIL; QF_ABORT should only be used if the list was changed). - Make qf_jump_edit_buffer actually switch to prevwin when using `:cXX` commands **outside** of the list window if 'wfb' is set in curwin. Handle autocommands properly in case they mess with the list. NOTE: previously, it seemed to split if 'wfb' was set, but do nothing and fail if prevwin is *valid*. This behaviour seemed strange, and maybe unintentional? Now it aligns more with what's described for the `:cXX` commands in the original PR description when used outside a list window, I think. - In both functions, only consider prevwin if 'wfb' isn't set for it; fallback to splitting otherwise. - Use win_split to split. Not sure if there was a specific reason for using ex_splitview. win_split is simpler and respects modifiers like :vertical that may have been used. Plus, its return value can be checked for setting opened_window in qf code (technically win_split_ins autocmds could immediately close it or change windows, in which the qf code might close some other window on failure; it's already the case elsewhere, though). closes: vim/vim#14142 https://github.com/vim/vim/commit/4bb505e28cac0389561fff78d8bbe0319c2bcf2f Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
* | vim-patch:9.1.0149: null pointer member access when accessing 'winfixbuf' ↵Colin Kennedy2024-03-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | property Problem: qf_goto_win_with_qfl_file may check if prevwin has 'winfixbuf' set without checking if it's valid first. Solution: Reverse the condition. Add a test, a modeline, and a missing CheckFeature. (Searn Dewar) closes: vim/vim#14140 https://github.com/vim/vim/commit/5131f224da93f2e042a4b22545ef62b1b2ab8460 Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
* | vim-patch:9.1.0147: Cannot keep a buffer focused in a windowColin Kennedy2024-03-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Cannot keep a buffer focused in a window (Amit Levy) Solution: Add the 'winfixbuf' window-local option (Colin Kennedy) fixes: vim/vim#6445 closes: vim/vim#13903 https://github.com/vim/vim/commit/215703563757a4464907ead6fb9edaeb7f430bea N/A patch: vim-patch:58f1e5c0893a
* | vim-patch:9.1.0164: Internal error when passing invalid position to ↵zeertzjq2024-03-11
| | | | | | | | | | | | | | | | | | | | | | getregion() (#27805) Problem: Internal error or crash when passing invalid position to getregion(). Solution: Give an error for invalid position (zeertzjq). closes: vim/vim#14172 https://github.com/vim/vim/commit/26dd09ad5e86f4e2179be0181421bfab9a6b3b75
* | vim-patch:9.1.0138: too many STRLEN calls when getting a memline (#27799)zeertzjq2024-03-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: too many STRLEN calls when getting a memline Solution: Optimize calls to STRLEN(), add a few functions in memline.c that return the byte length instead of relying on STRLEN() (John Marriott) closes: vim/vim#14052 https://github.com/vim/vim/commit/02d7a6c6cfceb3faf9c98fcb7c458760cd50d269 Cherry-pick line break changes from patch 8.1.0226. Cherry-pick ml_line_len from patch 8.1.0579. Cherry-pick test_comments.vim change from patch 9.1.0153. Co-authored-by: John Marriott <basilisk@internode.on.net>
* | revert: "fix(window): :close crash with autocmd, floats and tabpage" (#27796)zeertzjq2024-03-10
| | | | | | | | | | | | | | | | This reverts PR #27793. On second thought, this solution may still crash, because it can leave a window with a NULL buffer if there are autocommand windows or if closing a floating window fails. It also makes close_last_window_tabpage() more complicated, so revert it.
* | fix(window): :close crash if WinClosed from float closes window (#27794)zeertzjq2024-03-10
| | | | | | | | Problem: :close crash if WinClosed from float closes window. Solution: Check if window has already been closed.
* | fix(window): :close crash with autocmd, floats and tabpage (#27793)zeertzjq2024-03-10
| | | | | | | | Problem: :close crash with autocmd, floats and tabpage. Solution: Close floating windows in one more case.
* | vim-patch:9.1.0159: Crash in WinClosed after BufUnload closes other windows ↵zeertzjq2024-03-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#27792) Problem: Crash in WinClosed after BufUnload closes other windows Solution: Don't trigger WinClosed if the buffer is NULL (zeertzjq) Now win_close_othertab() doesn't trigger any autocommands if the buffer is NULL, so remove the autocmd blocking above (which was added not long ago in patch v9.0.0550) for consistency. Also remove an unreachable close_last_window_tabpage() above: - It is only reached if only_one_window() returns TRUE and last_window() returns FALSE. - If only_one_window() returns TRUE, there is only one tabpage. - If there is only one tabpage and last_window() returns FALSE, the one_window() in last_window() must return FALSE, and the ONE_WINDOW in close_last_window_tabpage() must also be FALSE. - So close_last_window_tabpage() doesn't do anything and returns FALSE. Then the curtab != prev_curtab check also doesn't make much sense, and the only_one_window() can be replaced with a check for popup and a call to last_window() since this is a stricter check than only_one_window(). closes: vim/vim#14166 https://github.com/vim/vim/commit/b2ec0da080fb24f12a8d6f54bd7318a078ca4e6c
* | vim-patch:9.1.0161: expand() removes slash after env variable that ends with ↵zeertzjq2024-03-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | colon (#27791) Problem: expand() removes a slash after an environment variable that ends with a colon on Windows. Solution: Check the correct char for a colon (zeertzjq) closes: vim/vim#14161 Note: Vim still removes the path-separator at the end, if another path separator follows directly after it, e.g. on: ``` echo $FOO='/usr/' echo expand('$FOO/bar') == '/usr/bar' ``` see: ,----[ misc1.c:1630 ] | // if var[] ends in a path separator and tail[] starts | // with it, skip a character | if (after_pathsep(dst, dst + c) | #if defined(BACKSLASH_IN_FILENAME) || defined(AMIGA) | && (dst == save_dst || dst[-1] != ':') | #endif | && vim_ispathsep(*tail)) | ++tail; `---- https://github.com/vim/vim/commit/13a014452a7a020a119ac555a690c65b41f3126d Cherry-pick test_expand.vim change from patch 9.0.1257.
* | Merge pull request #27330 from seandewar/win_set_config-fixesSean Dewar2024-03-09
|\ \ | | | | | | | | | | | | fix(api): various window-related function fixes This is a big one!
| * | vim-patch:8.2.3862: crash on exit with EXITFREE and using win_execute()Sean Dewar2024-03-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Crash on exit with EXITFREE and using win_execute(). Solution: Also save and restore tp_topframe. (issue vim/vim#9374) https://github.com/vim/vim/commit/dab17a0689a2f31f69f428975f84b0c3c7ba3030 Couldn't repro the crash in the test, but I only care about this patch so switch_win sets topframe properly for win_split_ins in nvim_open_win and nvim_win_set_config. Add a test using nvim_win_call and :wincmd, as I couldn't repro the issue via nvim_open_win or nvim_win_set_config (though it's clear they're affected by this patch). That said, at that point, could just use {un}use_tabpage inside switch_win instead, which also updates tp_curwin (though maybe continue to not set it in restore_win). That would also fix possible inconsistent behaviour such as: :call win_execute(w, "let curwin_nr1 = tabpagewinnr(1)") :let curwin_nr2 = tabpagewinnr(1) Where it's possible for curwin_nr1 != curwin_nr2 if these commands are run from the 1st tabpage, but window "w" is in the 2nd (as the 1st tabpage's tp_curwin may still be invalid). I'll probably PR a fix for that later in Vim. Co-authored-by: Bram Moolenaar <Bram@vim.org>
| * | fix(api): win_set_config set tp_curwin of win moved from other tabpageSean Dewar2024-03-09
| | | | | | | | | | | | | | | | | | | | | Problem: nvim_win_set_config does not update the tp_curwin of win's original tabpage when moving it to another. Solution: update it if win was the tp_curwin. Add a test.
| * | fix(window): :close may cause Nvim to quit with autocmd and floatzeertzjq2024-03-09
| | | | | | | | | | | | | | | | | | | | | Problem: :close may cause Nvim to quit if an autocommand triggered when closing the buffer closes all other non-floating windows and there are floating windows. Solution: Correct the check for the only non-floating window.
| * | test(old): remove Test_floatwin_splitmove()zeertzjq2024-03-09
| | | | | | | | | | | | | | | | | | Its corresponding test in Vim is in test_popupwin.win, so having it in the middle of test_window_cmd.vim is strange, and it is now covered by tests in ui/float_spec.lua anyway.
| * | fix(api): win_set_config update statuslines after removing splitsSean Dewar2024-03-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: nvim_win_set_config does not update statuslines after removing a split. Solution: call last_status. Didn't realize this was missing in the original nvim_win_set_config for splits PR. As it can only be done for the current tabpage, do it if win_tp == curtab; enter_tabpage will eventually call last_status anyway when the user enters another tabpage.
| * | fix(api): patch some cmdwin/textlock holesSean Dewar2024-03-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: there are new ways to escape textlock or break the cmdwin in nvim_win_set_config and nvim_tabpage_set_win. Solution: fix them. Use win_goto to check it in nvim_tabpage_set_win and use the try_start/end pattern like with similar functions such as nvim_set_current_win (which uses the existing msg_list, if set). Careful not to use `wp->handle` when printing the window ID in the error message for nvim_tabpage_set_win, as win_goto autocommands may have freed the window. On a related note, I have a feeling some API functions ought to be checking curbuf_locked...
| * | fix(api): handle win_split_ins failure properlySean Dewar2024-03-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: nvim_win_set_config does not handle failure in win_split_ins properly yet, which can cause all sorts of issues. Also nvim_open_win and nvim_win_set_config do not set the error message to the one from win_split_ins. Solution: handle failure by undoing winframe_remove, like in win_splitmove. Make sure autocommands from switching to the altwin fire within a valid window, and ensure they don't screw things up. Set the error message to that of win_split_ins, if any. Also change a few other small things, including: - adjust win_append to take a tabpage_T * argument, which is more consistent with win_remove (and also allows us to undo a call to win_remove). - allow winframe_restore to restore window positions. Useful if `wp` was in a different tabpage, as a call to win_comp_pos (which only works for the current tabpage) after winframe_restore should no longer be needed. Though enter_tabpage calls win_comp_pos anyway, this has the advantage of ensuring w_winrow/col remains accurate even before entering the tabpage (useful for stuff like win_screenpos, if used on a window in another tabpage). (This change should probably also be PR'd to Vim later, even though it doesn't use winframe_restore for a `wp` in a different tabpage yet).
| * | vim-patch:9.1.0130: [security]: UAF if win_split_ins autocommands delete "wp"Sean Dewar2024-03-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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) https://github.com/vim/vim/commit/abf7030a5c22257f066fa9c4061ad150d5a82577
| * | vim-patch:9.1.0128: win_gotoid() may abort even when not switching a windowSean Dewar2024-03-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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) https://github.com/vim/vim/commit/2a65e739447949a7aee966ce8a3b75521b2a79ea
| * | vim-patch:9.1.0121: Infinite loop or signed overflow with 'smoothscroll'Sean Dewar2024-03-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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) https://github.com/vim/vim/commit/02fcae02a926e4e8379d77fb716da4202029882d Test_window_split_no_room changes were already cherry-picked earlier.
| * | vim-patch:9.1.0119: can move away from cmdwin using win_splitmove()Sean Dewar2024-03-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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). https://github.com/vim/vim/commit/f865895c874b0936b0563ebfef7490aac8cb8a1f
| * | vim-patch:9.1.0118: Use different restoration strategy in win_splitmoveSean Dewar2024-03-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: saving and restoring all frames to split-move is overkill now that WinNewPre is not fired when split-moving. Solution: defer the flattening of frames until win_split_ins begins reorganising them, and attempt to restore the layout by undoing our changes. (Sean Dewar) https://github.com/vim/vim/commit/704966c2545897dfcf426dd9ef946aeb6fa80c38 Adjust winframe_restore to account for Nvim's horizontal separators when the global statusline is in use. Add a test.
| * | vim-patch:partial:9.1.0117: Stop split-moving from firing WinNew and ↵Sean Dewar2024-03-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | WinNewPre autocommands 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) https://github.com/vim/vim/commit/96cc4aef3d47d0fd70e68908af3d48a0dce8ea70 Partial as WinNewPre has not been ported yet (it currently has problems anyway).
| * | vim-patch:9.1.0116: win_split_ins may not check available roomSean Dewar2024-03-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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) https://github.com/vim/vim/commit/0fd44a5ad81ade342cb54d8984965bdedd2272c8 Omit WSP_FORCE_ROOM, as it's not needed for Nvim's autocmd window, which is floating. Shouldn't be difficult to port later if it's used for anything else. Make win_splitmove continue working for turning floating windows into splits. Move the logic for "unfloating" a float to win_split_ins; unlike splits, no changes to the window layout are needed before calling it, as floats take no room in the window layout and cannot affect the e_noroom check. Add missing tp_curwin-fixing logic for turning external windows into splits, and add a test. NOTE: there are other issues with the way "tabpage independence" is implemented for external windows; namely, some things assume that tp_curwin is indeed a window within that tabpage, and as such, functions like tabpage_winnr and nvim_tabpage_get_win currently don't always work for external windows (with the latter aborting!) Use last_status over frame_add_statusline, as Nvim's last_status already does this for all windows in the current tabpage. Adjust restore_full_snapshot_rec to handle this. This "restore everything" approach is changed in a future commit anyway, so only ensure it's robust enough to just pass tests. Keep check_split_disallowed's current doc comment, as it's actually a bit more accurate here. (I should probably PR Vim to use this one) Allow f_win_splitmove to move a floating "wp" into a split; Nvim supports this. Continue to disallow it from moving the autocommand window into a split (funnily enough, the check wasn't reachable before, as moving a float was disallowed), but now return -1 in that case (win_splitmove also returns FAIL for this, but handling it in f_win_splitmove avoids us needing to switch windows first). Cherry-pick Test_window_split_no_room fix from v9.1.0121. Update nvim_win_set_config to handle win_split_ins failure in later commits.
| * | fix(api): make open_win block only enter/leave events if !enter && !noautocmdSean Dewar2024-03-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: nvim_open_win blocking all win_set_buf autocommands when !enter && !noautocmd is too aggressive. Solution: temporarily block WinEnter/Leave and BufEnter/Leave events when setting the buffer. Delegate the firing of BufWinEnter back to win_set_buf, which also has the advantage of keeping the timing consistent (e.g: before the epilogue in enter_buffer, which also handles restoring the cursor position if autocommands didn't change it, among other things). Reword the documentation for noautocmd a bit. I pondered modifying do_buffer and callees to allow for BufEnter/Leave being conditionally disabled, but it seems too invasive (and potentially error-prone, especially if new code paths to BufEnter/Leave are added in the future). Unfortunately, doing this has the drawback of blocking ALL such events for the duration, which also means blocking unrelated such events; like if window switching occurs in a ++nested autocmd fired by win_set_buf. If this turns out to be a problem in practice, a different solution specialized for nvim_open_win could be considered. :-)
| * | fix(api): make win_set_config with "win" for splits need "split/vertical"Sean Dewar2024-03-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: currently, for splits, nvim_win_set_config accepts win without any of split or vertical set, which has little effect and seems error-prone. Solution: require at least one of split or vertical to also be set for splits. Also, update nvim_win_set_config docs, as it's no longer limited to just floating and external windows.
| * | fix(api): make open_win/win_set_config check if splitting allowedSean Dewar2024-03-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: splitting is disallowed in some cases to prevent the window layout changes while a window is closing, but it's not checked for. Solution: check for this, and set the API error message directly. (Also sneak in a change to tui.c that got lost from #27352; it's a char* buf, and the memset is assuming one byte each anyway)