summaryrefslogtreecommitdiffstatshomepage
path: root/test/functional/api/window_spec.lua
AgeCommit message (Collapse)AuthorFiles
2026-04-19feat(options): add 'winpinned' to pin a window #39157luukvbaal1
Problem: - Unable to "pin" a window to prevent closing without specifically being targeted. - :fclose closes hidden windows (even before visible windows). Solution: - Add 'winpinned' window-local option. When set, window is skipped by :fclose and :only. Pin the ui2 cmdline window (which should always be visible), so that it is not closed by :only/fclose. - Skip over hidden (and pinned) windows with :fclose. Co-authored-by: glepnir <glephunter@gmail.com>
2026-03-16fix(api): use standard error messagesJustin M. Keyes1
2026-03-14fix(api): improve external window validationSean Dewar1
Problem: "win" is allowed in external window configs in some cases. External window converted to normal float can't move tabpages in one nvim_win_set_config call. External window can't be turned into a normal split. Solution: disallow setting "win" for external windows. Allow external window to move tabpages, which turns it non-external. Allow external window to be turned into a (non-external) split. parse_win_config has more validation issues from not considering the window's existing config enough (not from this PR). For example, zindex can be set for an existing split if "split"/"vertical" isn't given, despite intending for that to be an error. Plus the logic is confusing. It could do with a refactor at some point...
2026-03-14fix(api): disallow moving window between tabpages in more casesSean Dewar1
Problem: more cases where it may not be safe to move a window between tabpages. Solution: check them. Rather speculative... I haven't spend much time looking, but I didn't find existing code that sets these locks to skip checking win_valid. (what I did find called it anyway, like in win_close) Still, I think it's a good precaution for what future code might do. If the fact that nvim_win_set_config *actually* moves windows between tabpages causes unforeseen issues, "faking" it like ":wincmd T" may be an alternative: split a new window, close the old one, but instead also block autocmds, copy the old window's config, and give it its handle?
2026-03-14feat(api): nvim_win_set_config can move split to other tp as floatwinSean Dewar1
Problem: not possible for nvim_win_set_config to convert a split to a floatwin, then move it to another tabpage in one call. Solution: allow it.
2026-03-14fix(winfloat): last_status when changing split to floatwinSean Dewar1
Problem: converting a split to a floatwin may not remove the last statusline when needed. (e.g: 'ls' is 1) Solution: call last_status/win_comp_pos in win_new_float, after win_remove. Also fix float_pos formatting for screen snapshots so it doesn't give a nil error for external windows. Not an issue from this PR.
2026-03-14fix(api): relax config validation for "win"Sean Dewar1
Problem: only possible to move floats between tabpages if relative=win, which has the restrictive effect of also anchoring it to the target window. Solution: allow "win" without "relative" or "split"/"vertical". Only assume missing "win" is 0 if relative=win is given to maintain that behaviour. (or when configuring a new window) Also add an error when attempting to change a split into a float that's in another tabpage, as this isn't actually supported yet. (until the next commit) Maybe this could do with some bikeshedding. Unclear if "win" should require "relative" to be given, like with "row"/"col"; this can be annoying though as specifying "relative" requires other fields to be given too.
2026-03-14refactor(api): cleanup, more comments, more tests, newsSean Dewar1
- Factor out logic to keep nvim_win_set_config clean. - Clean up a few things, remove redundant logic, reflow some lines. - Add some more comments where appropriate. - Don't consider negative "win", as that's only relevant for splits. - Add more test coverage. - Add news.txt entry.
2026-03-14feat(api): nvim_win_set_config can move floatwin to another tabpageglepnir1
Problem: nvim_win_set_config can't move floating windows to different tab pages. Solution: allow it. Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
2026-03-14fix(window): don't leak fold memory with style=minimal #38287Sean Dewar1
Problem: discarding saved option values in the WinInfo of closed style=minimal windows leaks memory. Solution: also free the nested folds.
2026-03-09Merge #38206 nvim_win_set_configJustin M. Keyes1
2026-03-09fix(api): don't re-apply minimal style if unchanged #38152Sean Dewar1
Problem: nvim_win_set_config with style=minimal re-applies option values even if the new style is unchanged from the old. This may be undesirable after #38122. Solution: don't bother in this case. See https://github.com/neovim/neovim/pull/38122#issuecomment-3996994189. A reversal of https://github.com/neovim/neovim/pull/22865#discussion_r1161598973 so its associated test has been updated.
2026-03-09fix(api): unnecessary errors when not moving splitSean Dewar1
Problem: nvim_win_set_config may raise unnecessary errors when not moving a split. Solution: skip checks related to moving when only maybe resizing a split.
2026-03-09fix(api): redraw after setting minimal styleSean Dewar1
Problem: No explicit redraw after setting style=minimal in nvim_open_win or nvim_win_set_config, which may cause it to appear like it's not set. Solution: call changed_window_setting after applying the style, which should be enough for these options.
2026-03-08fix(api): merge split window config only on successSean Dewar1
Problem: nvim_win_set_config may merge configs despite failing to configure a split, and without applying necessary side-effects (like setting style=minimal options). Plus, autocommands may apply a different config after the merge, causing side-effects to apply for an outdated config. Solution: merge configs last, only on success. Include fields only relevant to splits. Properly set _cmdline_offset for splits. Maybe better to disallow _cmdline_offset for splits instead, as the pum is relative to cmdline_row anyway? (I didn't want to change behaviour too much) Also use expect_unchanged in an unrelated test to quash a warning.
2026-03-08fix(api): style=minimal not applied immediately for unmoved splitSean Dewar1
Problem: nvim_win_set_config with style="minimal" does not take immediate effect when a split is not moved. Solution: don't skip nvim_win_set_config's epilogue when only a resize may be needed. De-duplicate resize logic and remove unnecessary redraw. (win_set*_win already handles that)
2026-03-03fix(api): return "style" in nvim_win_get_config() #38122Sean Dewar1
Problem: nvim_win_get_config() does not return a window's "style". Solution: always include it, and document `style=""`. Always included so it can be used reciprocally with nvim_open_win() or nvim_win_set_config(). (otherwise the config of a window with kWinStyleUnused will not unset the kWinStyleMinimal style of another window if passed to nvim_win_set_config, for example)
2026-02-12fix(api): preserve WinConfig style when converting float to split #37264glepnir1
Problem: When a float window with style='minimal' is converted to a split window and then changes buffer, the minimal style options get overridden. This happens because merge_win_config() clears the style field, so get_winopts() doesn't know to re-apply minimal style after restoring options from the buffer's wininfo. Solution: Save and restore the style field when clearing the config during float-to-split conversion.
2025-12-21fix(api): open_win leak from naughty autocommandsSean Dewar1
Problem: error set by win_set_buf may leak if autocommands immediately close the new window. Solution: free the error set by win_set_buf. (prefer nvim_open_win's error as it's more important and will cause 0 to be returned)
2025-12-21fix(api): ignore split_disallowed when opening a floatSean Dewar1
Problem: split_disallowed seemingly exists to prevent issues from changing frames to accomodate a split window, which doesn't apply to floats. Solution: remove the restriction for nvim_open_win, but only for floats. (continue to check b_locked_split though) NOTE: like before, the buffer we check b_locked_split for may not actually be the target buffer "buf", as the later call to win_set_buf can fail to switch to "buf" due to autocommands. (among other things) Maybe we could attempt to close the new window in that case (or switch to a different buffer if that also fails), but this is safer. (and simpler) Fixes #36857 (and possibly some spurious E242s I've observed from extui)
2025-11-22docs: misc, build, lspJustin M. Keyes1
2025-11-18feat(api): nvim_win_set_config accepts unchanged "noautocmd" #36463glepnir1
Problem: Cannot reuse same config with noautocmd for both window creation and updates, even when value is unchanged. Solution: Only reject noautocmd changes for existing windows.
2025-10-08fix(api): nvim_open_win default to half-size for splits (#36088)Sean Dewar1
Problem: after #35601, nvim_open_win incorrectly attempts to set the size of a split window to 0 if it wasn't specified. Solution: only attempt to set the size again if it was actually specified. This has the effect of defaulting to half the size of the parent window (or it may be equalized with other windows to make room), like before. Fix #36080
2025-10-04fix(api): nvim_open_win respects requested split window size (#35601)glepnir1
Problem: requested window size passed to nvim_open_win for splits may be ignored by win_split_ins if it decides to forcefully equalize window sizes instead (e.g: in an attempt to make room for the new window). Solution: try to set the size again if it differs from what was requested. Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
2025-09-08fix(api): crash when moving curwin to other tabpage #35679glepnir1
Problem: nvim_win_set_config may crash when attempting to move curwin to a different tabpage if there is no other non-float available to switch to. Solution: fix the crash. Fix ONE_WINDOW checks in winframe_find_altwin and win_altframe to consider floating windows by instead using one_window. Allow one_window to consider non-current tabpages. We can use one_window in win_close_othertab now to also better reflect its use in win_close. Co-authored-by: Sean Dewar <6256228+seandewar@users.noreply.github.com>
2025-09-06fix(api): win_set_config error message for splitting from a float #35650Sean Dewar1
Problem: after #34287 nvim_win_set_config no longer errors when attempting to split from a floating window only if "win" is 0. Solution: fix the regression, reduce the scope of "parent" and similar checks to only where it's currently used and add test coverage for the errors.
2025-07-22fix(api): do not allow opening float to closing bufferSean Dewar1
Problem: no check for nvim_open_win opening a new floating window into a closing buffer, which can lead to crashes. Solution: call check_split_disallowed; opening a new float semantically splits from a window, so the same problems as regular splits apply. Also restore the error if switch_win_noblock in win_set_buf fails (may not be possible to hit this, but win_set_buf can silently succeed there since #31595). As the lock check applies to curbuf (not the target buffer) this may feel a bit restrictive, though this isn't different to how things like ":split" or nvim_open_win with "split = true" works when targeting a different buffer. Only checking the target buffer's lock will cause issues if win_set_buf doesn't end up in the target buffer for whatever reason. Maybe we could consider checking the lock of the buffer after win_set_buf and close the window if it's locked (maybe a bit fiddly, especially as closing a window can fail...), or make the open + switch operation more atomic, like how Vim does for its popup windows..? It also used to be the case that win_set_buf would set an error if autocommands sent us to a different buffer than what was requested, but #31595 appears to have also changed that... I haven't touched that here.
2025-07-22fix(window): restore b_nwindows if win_close_othertab keeps windowSean Dewar1
Problem: can't accurately know if close_buffer directly (e.g: not via autocmds) decremented b_nwindows. This can cause crashes if win_close_othertab decides to keep the window after calling close_buffer (if it did not free the buffer), as b_nwindows may remain out-of-sync. Solution: change the return value of close_buffer to accurately depict whether it decremented b_nwindows. Check it in win_close_othertab to avoid a crash. Similar issues may exist in other places that call close_buffer, but I've not addressed those here (not to mention only one other place even checks its return value...)
2025-07-22fix(window): handle closing the only non-float in other tabpageSean Dewar1
Problem: No check for closing the only non-floating window in a non-current tabpage that contains floats. This can lead to a tabpage that contains only floats, causing crashes. Solution: Copy the relevant check from win_close to win_close_othertab. Fix some uncovered issues. Closes #34943 Fixes #31236 Co-authored-by: glepnir <glephunter@gmail.com>
2025-06-14fix(window): don't enter unfocusable or hidden prevwin (#34486)luukvbaal1
Problem: When closing a floating window, the next window to be entered may be unfocusable or hidden. Solution: Don't enter prevwin when it is unfocusable or hidden. Enter firstwin instead (like for when prevwin is no longer valid).
2025-05-04vim-patch:9.1.1361: [security]: possible use-after-free when closing a ↵Sean Dewar1
buffer (#33820) Problem: [security]: Possible to open more windows into a closing buffer without splitting, bypassing existing "b_locked_split" checks and triggering use-after-free Solution: Disallow switching to a closing buffer. Editing a closing buffer (via ":edit", etc.) was fixed in v9.1.0764, but add an error message and check just "b_locked_split", as "b_locked" is necessary only when the buffer shouldn't be wiped, and may be set for buffers that are in-use but not actually closing. (Sean Dewar) closes: vim/vim#17246 https://github.com/vim/vim/commit/6cb1c828406dcbb9b67ee788501b94f3a0bac88a
2025-04-21feat(options): default statusline expression #33036Shadman1
Problem: Default 'statusline' is implemented in C and not representable as a statusline expression. This makes it hard for user configs/plugins to extend it. Solution: - Change the default 'statusline' slightly to a statusline expression. - Remove the C implementation.
2025-04-21feat(api): add "max_height" argument to nvim_win_text_height (#32835)luukvbaal1
Useful to e.g. limit the height to the window height, avoiding unnecessary work. Or to find out how many buffer lines beyond "start_row" take up a certain number of logical lines (returned in "end_row" and "end_vcol").
2025-04-19test(api/window_spec): check start_vcol on folded line (#33535)zeertzjq1
2025-04-19test(api): nvim_win_text_height with virt_lines around fold (#33529)zeertzjq1
2025-03-19fix(api): don't use 'winborder' when reconfiguring float (#32984)glepnir1
Problem: Reconfiguring a float window applies the global 'winborder'. Solution: - Ignore 'winborder' when reconfiguring a float window. - Still apply 'winborder' when converting a split to a float window.
2025-03-19fix(api): fix 'winborder' preventing splits with nvim_open_win (#32981)zeertzjq1
While at it, rename the p_winbd variable to p_winborder, as 'winbd' is not the option's short name. Co-authored-by: glepnir <glephunter@gmail.com>
2025-01-20Merge pull request #31597 from bfredl/deletionismbfredl1
fix(wininfo): when freeing windows, free the lowest priority wininfo
2025-01-14fix(wininfo): when freeing windows, free the lowest priority wininfobfredl1
On master (and also before #31539) closing a window could cause the used wininfo for a buffer to change. This is due to always removing the previous NULL wininfo when deleting a window, even if that wininfo had higher priority than the the deleted window's own wininfo. Instead delete the wininfo with lowest priority. This retains the memory saving efect while not affecting the effective value of window options and so on.
2024-12-16fix(api): generic error messages, not using TRY_WRAP #31596Justin M. Keyes1
Problem: - API functions using `try_start` directly, do not surface the underlying error message, and instead show generic messages. - Error-handling code is duplicated in the API impl. - Failure modes are not tested. Solution: - Use `TRY_WRAP`. - Add tests.
2024-12-16fix(api): not using TRY_WRAP, generic error messages #31595Justin M. Keyes1
Problem: - API functions using `try_start` directly instead of `TRY_WRAP`, do not surface the underlying error message, and instead show generic things like "Failed to set buffer". - Error handling code is duplicated in the API impl, instead of delegating to the vim buffer/window handling logic. Solution: - Use `TRY_WRAP`.
2024-11-14fix(tests): needing two calls to setup a screen is cringebfredl1
Before calling "attach" a screen object is just a dummy container for (row, col) values whose purpose is to be sent as part of the "attach" function call anyway. Just create the screen in an attached state directly. Keep the complete (row, col, options) config together. It is still completely valid to later detach and re-attach as needed, including to another session.
2024-09-28fix(window): making float with title/footer non-float leaks memory (#30551)zeertzjq1
2024-09-27fix(api): fix crash/leak with float title/footer on error (#30543)zeertzjq1
2024-09-27test(api/window_spec): remove duplicate test (#30538)zeertzjq1
2024-06-28refactor: use `vim._with` where possibledundargoc1
This mostly means replacing `nvim_buf_call` and `nvim_win_call` with `vim._with`.
2024-05-26refactor(tests): use more global highlight definitionsbfredl1
2024-04-25feat(api): allow floats to be opened in non-current tabpage (#28480)Will Hopkins1
\
2024-04-23test: improve test conventionsdundargoc1
Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004.
2024-04-21fix(api): do not update grid position in nvim_win_set_cursor (#28235)luukvbaal1
Revert commit c971f538ab87b537ae4c97bd44167661c5691a2d. Forcing grid cursor position will need a new API like originally proposed in #27858.