Problem: Wrong terminal scrollback if BufFile* autocommand drains PTY
output but doesn't process the pending refresh.
Solution: Refresh scrollback before refreshing screen in terminal_open()
if scrollback has been allocated.
Problem:
The :intro fails to display in ui2 because wait_return(true) triggers a full
redraw. Furthermore statuslines are visible when using :intro
Solution:
Replace wait_return() with plain_vgetc(). This works with old and ui2 while also removing the unnecessary statusline and "press ENTER" prompt.
Updates tests to work with new behaviour.
Signed-off-by: ashab-k <ashabkhan2000@gmail.com>
Problem:
Two cases lsp.enable() won't work in the first FileType event
1. lsp.enable luals inside FileType or ftplugin/lua.lua, then:
```
nvim a.lua
```
2. lsp.enable luals inside FileType or ftplugin/lua.lua, then:
```
nvim -> :edit a.lua -> :mksession! | restart +qa! so Session.vim
```
Solution:
Currently `v:vim_did_enter` is used to detected two cases:
1. "maunally enabled" (lsp.enable() or `:lsp enable`)
2. "inside FileType event"
To detect 2. correctly we use did_filetype().
Problem:
Calling os_chdir() to change the child processes' CWD may cause some
unnecessary UI events to be buffered. These UI events don't go anywhere
as execvp() is called before flushing the UI buffer.
Solution:
Use uv_chdir() instead of os_chdir(). Also fix getting error string
incorrectly. Add test for the current behavior.
Problem: Terminal loses output if a BufFilePre or BufFilePost autocmd
polls for events.
Solution: Rename the buffer after allocating the terminal instance. Also
fix buffer getting wrong name if BufFilePre uses NameBuff.
Problem: There are still ways to run into textlock errors with
vim.ui_attach callbacks trying to display a UI event.
Solution: Disregard textlock again during vim.ui_attach() callbacks
(also when scheduled). Partially revert 3277dc3b; avoiding
to flush while textlock is set is still helpful.
* cache all tokens from various range requests for a given document
version
- all new token highlights are merged with previous highlights to
maintain order and the "marked" property
- this allows the tokens to stop flickering once they've loaded once
per document version
* abandon the processing coroutine if the request_id has changed instead
of relying only on the document version
- this will improve efficiency if a new range request is made while a
previous one was processing its result
* apply new highlights from processing coroutine directly to the current
result when the version hasn't changed
- this allows new highlights to be immediately drawable once they've
processed instead of waiting for the whole response to be processed
at once
* rpc layer was changed to provide the request ID back in success
callbacks, which is then provided as a request_id field on the handler
context to lsp handlers
Usually, terminal_close() calls refresh_terminal(), which allocates the
scrollback buffer, and term_may_alloc_scrollback() in terminal_open()
won't dereference the buffer. However, refresh_terminal() is not called
during Nvim exit, in which case a heap-use-after-free may happen if
TermOpen wipes buffer. Check for non-NULL buf_handle to avoid that.
Problem: When TermOpen polls for enough events to use the scrollback
buffer, scrollback is lost until the next terminal refresh.
Solution: Allocate the scrollback buffer when it's needed.
Problem: Fast context for msg_show event inhibits vim.ui_attach from
displaying a stream of messages from a single command.
Solution: Remove fast context from msg_show events emitted as a result
of explicit API/command calls. The fast context was originally
introduced to prevent issues with internal messages.
Problem: Esc on commandline executes command instead of abandoning it.
Solution: Save and restore KeyTyped when removing the popup menu.
(closesvim/vim#10154)
11a57dfd16
No code change is needed in Nvim as Nvim doesn't call update_screen() to
redraw pum.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Multiple eol_right_align virtual texts with different widths
are incorrectly positioned. The lookahead loop uses `item` instead of
`lookaheadItem` when checking kind and accessing data, causing all
items to use the first item's width.
Solution: Use `lookaheadItem->kind` and `lookaheadItem->data.vt`
instead of `item->kind` and `item->data.vt` in the lookahead loop.
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: has("terminfo") test fails on local runs because it expects
"HAVE_UNIBILIUM " in the :version info to mean that nvim was built
without unibilium.
Solution: Assume nvim is built with unibilium if HAVE_UNIBILIUM is
present in the version string and is NOT followed by 0, false, or off.
This isn't affecting CI runs because when the test detects that it is
running in CI it doesn't use the :version string at all.
Resolves https://github.com/neovim/neovim/issues/37456
* test(core/channels_spec): fix flaky test
Always use expect_stdout() to check PTY output.
* test(autocmd/termxx_spec): fix flaky test
Usually the Ctrl-C cancels the following :qa!, but sometimes it doesn't,
and Nvim exits before feed() returns. Instead make sure that :qa! always
reaches Nvim and use expect_exit().
Problem:
Crashed Nvim leaves socket files. Subsequent starts fail with "address already in use".
Solution:
On bind failure, test socket liveness via connect(). Remove if stale, retry bind().
Fixes#36581
Problem:
With shadow border, scrollbar and border overlap. Shadow's right border
starts from the second row (offset by 1), but scrollbar renders on every
row including the first. If they share a column, the first row shows
scrollbar where shadow hasn't started yet, causing misalignment.
Solution:
Separate scrollbar from the shadow's right border.
Problem: A message ending in an unprintable character may emit a
msg_show event with the "empty" kind. No empty message event
for echom "".
Solution: Adjust conditions for emitting "empty" msg_show events.
Problem:
Creating an autocommand which executes `:bwipe` on the Syntax event
causes a heap-use-after-free.
Solution: set BF_SYN_SET flag before applying autocommands
Problem:
When text is too long, it overflows into the border. This happens because
grid_line_maxcol includes border columns, so grid_line_puts can write
there.
Solution:
Truncate string to available width when need_fcs_trunc is set.
When width1 and width2 are negative the assertion may fail. It seems
that adding a negative value to w_curswant won't cause any problems, so
just change the assertion.
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: Error message for layout change does not match action.
Solution: Pass the command to where the error is given. (closesvim/vim#11573)
9fda81515b
Thinking about this again, it's actually OK to check split_disallowed in
window_layout_locked(), so add the check.
Also add missing window_layout_locked() in tabpage_close().
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: A lot of test cases require executing `vim.pack.add()` inside
`testnvim` instance to install and/or add plugins. This requires
access to the information about tested repo sources (stored in a Lua
variable inside a runner instance), so it needs to go
`exec_lua(function() vim.pack.add({...}) end)` route, which in
formatted form adds two more lines. Since it is very frequent, it pads
test files with (mostly avoidable and unncessary) lines.
Solution: Add `vim_pack_add()` helper specifically to execute
`vim.pack.add` inside `testnvim` instance. Use it where possible:
usually when `vim.pack.add` is not a subject of the test. It is not
quite doable for some cases, though:
- When error in `vim.pack.add` is tested.
- When specification includes `vim.version.range` (since `exec_lua`
seems to not transfer necessary class metatables).
This removes ~100 lines from the file at the cost of sometimes using
`vim_pack_add` and sometimes having to reside to `vim.pack.add`.
Which seems like a positive trade-off.
This also allows making a more compact `exec_lua('vim.pack.update()')`
instructions since `vim.pack.update` doesn't depend on the upvalues
stored in test runner instance.
Problem: `vim.pack` tests might benefit from a cleanup
Solution: Do the cleanup:
- Use `t.retry` instead of full `vim.uv.sleep` to make tests quicker.
- Use `pack_assert_content` helper for a common task of checking the
content of a special Lua file inside an installed plugin. This is
used as a proxy of installed plugin's state on the disk.
- Use `([[...]]):format()` approach (instead of array of strings) in
one more place. Should improve readability.
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.
Problem: Spell navigation skips words on the first line because
_on_spell_nav passes an empty range (0,0) to the highlighter.
Solution: Use math.max(erow, srow + 1) to ensure a valid search window.
Signed-off-by: ashab-k <ashabkhan2000@gmail.com>
Problem:
`t.skip()` adds to the "pending" list. If there is no path to fixing
a pending test, it adds noise to the pending list.
Solution:
Return early instead of using `t.skip()`.
Problem: Use-after-free in winframe_remove() (henices)
Solution: Set window_layout_locked() inside winframe_remove()
and check that writing diff files is disallowed when the
window layout is locked.
It can happen with a custom diff expression when removing a window:
1. Buffer was removed, so win_frame_remove() is called to remove the
window.
2. win_frame_remove() → frame_new_height() → scroll_to_fraction()
→ diff_check_fill() (checks for filler lines)
3. diff_check_fill() ends up causing a diff_try_update, and because we
are not using internal diff, it has to first write the file to a
buffer using buf_write()
4. buf_write() is called for a buffer that is not contained within a
window, so it first calls aucmd_prepbuf() to create a new temporary
window before writing the buffer and then later calls
aucmd_restbuf(), which restores the previous window layout, calling
winframe_remove() again, which will free the window/frame structure,
eventually freeing stuff that will still be accessed at step 2.
closes: vim/vim#19064ead1dda74a
Nvim doesn't have this bug as Nvim uses a floating window as autocommand
window, and removing it doesn't need winframe_remove().
Co-authored-by: Christian Brabandt <cb@256bit.org>
On linux /dev/stdin is defined as a symlink to /proc/self/fd/0
This in turn is defined as a "magic" symlink which is allowed to point
to internal kernel objects which really does not have a file
name. As a glaring inconsistency, fopen("/proc/self/fd/0", "r")
works if fd was originally opened using pipe() but not using
socketpair(). As it happens UV_CREATE_PIPE does not create pipes
but creates socket pairs. These two unfortunate conditions
means that using /dev/stdin and similar does not work in
shell commands in nvim on linux. as a work around, override
libuv's descicion and create an actual pipe pair.
This change is not needed on BSD:s but done unconditionally for simplicity,
except for on windows where it is not done for stdout because of windows
fixes#35984