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...
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?
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.
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.
- 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.
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>
Problem: nvim_parse_cmd rejects valid commands like `:1` (range-only)
or `aboveleft` (modifier-only).
Solution: allow empty command when range or modifiers exist, and handle
execution using existing range command logic.
Problem:
In autocmd examples, using "args" as the event-object name is vague and
may be confused with a user-command.
Solution:
Use "ev" as the conventional event-object name.
Problem:
When stopping a PTY process on Windows, the exit code indicates that the
process is stopped by SIGTERM even when closing all streams is enough to
terminate the process. This is inconsistent with other platforms.
Solution:
Set exit_signal to SIGHUP instead of SIGTERM when using SIGHUP.
Problem:
Exit code in :terminal channel test depends on whether the shell or Nvim
TUI in the terminal has registered its SIGHUP handler when jobstop() is
called.
Solution:
Don't use a shell as shells on different systems may handle SIGHUP
differently. Add a screen:expect() to wait for the TUI to start.
Problem: Exception error message only prints the first chunk of a
multi-chunk nvim_echo() message.
Solution: Concatenate consecutive message chunks in the exception
message list.
Problem:
When a terminal process exits, "[Process Exited]" text is added
to the buffer contents.
Solution:
- Return `exitcode` field from `nvim_get_chan_info`.
- Show it in the default 'statusline'.
- Show exitcode as virtual text in the terminal buffer.
Problem:
There is an inconsistency between extmarks/highlights regarding the
`end_col` param.
Solution:
Allow end_col=-1 to mean "end of line" (if strict=false).
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
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.
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.
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.
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)
Problem: Calling nvim_set_hl() with url= crashes because it tries to
free arena-owned string memory.
Solution: Remove the bad free and return a validation error instead.
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)
Problem: Leading message newlines (not emitted with ext_messages since
4260f73) were responsible for resetting the redirection message
column (while the newline itself is later pruned...).
Solution: Ensure the redirection column is reset at the start of a message.
(Instead of re-adjusting all the newline callsites which can
themselves hopefully be pruned if ext_messages is enabled by
default.)
Problem:
TUI does not support several standard SGR text attributes:
- dim/faint (SGR 2)
- blink (SGR 5)
- conceal (SGR 8)
- overline (SGR 53)
This means that when a program running in the embedded terminal emits
one of these escape codes, we drop it and don't surface it to the
outer terminal.
Solution:
- Add support for those attributes.
- Also add corresponding flags to `nvim_set_hl` opts, so users can set
these attributes in highlight groups.
- refactor(highlight): widen `HlAttrFlags` from `int16_t` to `int32_t`
Widen the `rgb_ae_attr` and `cterm_ae_attr` fields in HlAttrs from
int16_t to int32_t to make room for new highlight attribute flags,
since there was only one spare bit left.
- The C flag is named HL_CONCEALED to avoid colliding with the
existing HL_CONCEAL in syntax.h (which is a syntax group flag, not
an SGR attribute).
- Also note that libvterm doesn't currently support the dim and overline
attributes, so e.g. `printf '\e[2mThis should be dim\n'` and `printf
'\e[53mThis should have an overline\n'` are still not rendered
correctly when run from the embedded terminal.
Define a CMake target for every subdirectory of test/functional that
contains functional tests, and a functionaltest_parallel target that
depends on all those targets, allowing multiple test runners to run in
parallel.
On CI, use at most 2 parallel test runners, as using more may increase
system load and make tests unstable.
Problem: Opening a terminal on an empty buffer produces a spurious
buffer update event.
Solution: Don't call deleted_lines_buf() if no lines have been deleted.
Problem: A multi-line extmark that ends exactly at a deleted range end
is not invalidated.
Revalidated sign mark is added with incorrect range.
Solution: Remove questionable invalidation range condition which was
originally added to avoid deleting a mark that ends below a
deleted line.
Since splicing for a deleted line, and a replaced range that
explicitly ends at column 0 beyond a deleted line is identical,
we can't try to distinguish these two cases. I.e. :1delete 1
and nvim_buf_set_text(0, 0, 0, 1, 0, {}) yield the same splice
operation.
This means that a multi-line sign_text mark should now span at
least one column beyond its end_row, as seen in the adjusted
test. This is still somewhat unexpected/inconvenient to me
which is what prompted me to try to avoid it with the original
condition.
Add revalidated sign mark back to decor with correct range;
third sign mark added to test exposed a crash.
Problem: if init_prompt replaces the prompt line at the ': mark, it calls
inserted_bytes with the wrong lnum.
Solution: use the correct lnum. Call appended_lines_mark instead when appending
the prompt at the end.
Problem: prompt_setprompt does not adjust extmarks or trigger on_bytes
buffer-updates when fixing the prompt line.
Solution: adjust them, trigger on_bytes.
Notably, hides extmarks when replacing the entire line (and clearing user
input). Otherwise, when just replacing the prompt text, hides extmarks there,
but moves those after (in the user input area) to the correct spot.
Problem: Setting 'winhighlight' doesn't after setting global namespace
using nvim_win_set_hl_ns().
Solution: Check if using another namespace when setting 'winhighlight'
instead of disabling 'winhighlight' in nvim_win_set_hl_ns().
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.
Problem: Tests for deprecated highlight API were mixed with current API tests.
Solution: Move them to deprecated_spec.lua and update highlight_spec.lua to use nvim_get_hl.
Problem: Message ID is not incremented without ext_messages.
Solution: Increment where callstack reaches without ext_messages.
There is no clear place marking the end of internal
messages without ext_messages so IDs are only incremented
with `nvim_echo` calls. Message IDs are currently not exposed
anywhere but the msg_show event for this to matter.
Problem:
On Windows, writing to a pipe doesn't work if the pipe isn't connected
yet. This causes an RPC request to a session newly created by connect()
to hang, as it's waiting for a response to a request that never reaches
the server.
Solution:
Wait for uv.pipe_connect() callback to be called when using connect().
fix(api): auto-load buffers in nvim_buf_set_* operations
Problem: Setting marks, lines, or text on unloaded buffers fails because
ml_line_count is not accurate until the buffer is loaded.
Solution: Add require_loaded_buffer() helper and use it in write operations
(nvim_buf_set_lines, nvim_buf_set_text, nvim_buf_set_mark). These now
auto-load buffers as needed.
Problem: nvim_parse_expression null pointer dereference with unmatched ]
followed by a node.
Solution: if ast_stack was empty, set new_top_node_p to top of the stack after
pushing the list literal node; similar to what's done for curlies.
This bug was originally found by a Matrix user, but I couldn't remember how to
trigger it... Ran into the other crash while finding a repro. :P
Problem: nvim_parse_expression null pointer dereference when parsing an
identifier followed by { with "highlight" parameter set to false.
Solution: only set opening_hl_idx if pstate->colors is not NULL.
Not added to parser_tests.lua as that uses highlight = true.
Problem: nvim_get_option_value with "filetype" set can crash if autocommands
open the dummy buffer in more windows, or if &bufhidden == "wipe".
Solution: Attempt to close all dummy buffer windows before wiping. Promote the
dummy buffer to a normal buffer if that fails.
Problem: When the "filetype" key is set for nvim_get_option_value, autocommands
can crash Nvim by prematurely wiping the dummy buffer, or cause options intended
for it to instead be set for unrelated buffers if switched during OptionSet.
Solution: Don't crash. Also quash side-effects from setting the buffer options.
This fixes a regression from cf6f60ce4d
(possibly), as before that commit a frame is popped from the call stack
immediately after its response is received.
Also fix leaking the allocated error messages.
Problem:
Using nvim_set_current_win() to switch windows while in Visual mode
causes E315 ml_get error when target buffer has fewer lines. This
doesn't happen with `:wincmd w` since it properly resets Visual mode
when switching buffers.
Solution:
Reset Visual mode when switching to another buffer, like `:wincmd w`.