19134 Commits

Author SHA1 Message Date
66f02ee1fe vim-patch:9.1.1498: completion: 'complete' funcs behave different to 'omnifunc' (#34718)
Problem:  completion: Functions specified in the 'complete' option did
          not have the leader string removed when called with findstart = 0,
          unlike 'omnifunc' behavior
Solution: update behaviour and make behaviour consistent (Girish Palya)

closes: vim/vim#17636

fa16c7ab3f

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-06-30 23:58:06 +00:00
d6d1bfd20d fix(term): terminal attr index may exceed TERM_ATTRS_MAX #34318
Problem: Currently terminal highlight attribute buffers are statically allocated
be the size of `TERM_ATTRS_MAX`. This unique case isn't respected in
some places in the ui_compositor. Due to this, when a terminal window
has lines longer them `TERM_ATTRS_MAX`, the compositor will go past the
end of the buffer causing a crash due to out of bounds access.

Solution: Add check to ensure we don't query terminal highlight attrs
past `TERM_ATTRS_MAX` in `win_line()`.

Fixes #30374
2025-06-30 06:22:42 -07:00
ed7ff848a0 fix(prompt): prompt mark not placed after text edits correctly #34671 2025-06-30 03:19:43 -07:00
f7c939fa7a fix(exrc): exrc knows its own location (#34638)
fix(exrc): lua exrc files know their location

Problem:
'exrc' files are inherently bound to their location / workspace and
therefore require to "know" their location on the filesystem. However,
currently using `debug.getinfo(1, 'S')` returns `"<nvim>"`.

Solution:
Include the filepath as chunkname in `loadstring()` and `nlua_exec()`.
2025-06-29 10:19:10 -05:00
1c52e90cd5 fix(help): :help can focus unfocusable/hide window #34442
Problem:
:help/:helpgrep/:lhelpgrep can focus unfocusable/hide window

Solution:
Ignore unfocusable/hidden window when reusing help buffer.
2025-06-29 14:44:17 +00:00
331de6afa6 fix(tui): don't crash when nvim__screenshot() is called with bad path (#34594)
Problem: Currently `vim.api.nvim__screenshot()` crashes when called with an
invalid path. This is because we don't check if `fopen()` returns a null
pointer.

Solution: Bail out if `fopen()` returns a null pointer.

Fixes: https://github.com/neovim/neovim/issues/34593
2025-06-28 23:12:42 +00:00
10a03e83e3 fix(messages): only msg_clear for UPD_CLEAR #34688
Problem:  "msg_clear" is emitted after resizing the screen and during startup.
Solution: Only emit "msg_clear" when `redraw_type == UPD_CLEAR`.
2025-06-28 10:37:21 -07:00
64753b5c37 fix(highlight): spurious underline in 'winblend' floating window #34614
Problem: When a floating window with high winblend uses a highlight group
         with underline (but without guisp), the underline appears red.

Solution: Only blend the special color (for underline/undercurl) if the
          foreground highlight actually has underline or undercurl set.
          Otherwise, ignore the special color.
2025-06-27 02:52:28 -07:00
0b91e9f83b vim-patch:9.1.1482: scrolling with 'splitkeep' and line() (#34670)
Problem:  Topline is preemptively updated by line() in WinResized
          autocmd with 'splitkeep' != "cursor".
Solution: Set `skip_update_topline` when 'splitkeep' != "cursor".
          (Luuk van Baal)

fe803c8c04
2025-06-27 11:16:23 +02:00
2b4c1127ad feat(ui): emit "msg_clear" event after clearing the screen (#34035)
Problem:  ext_messages cannot tell when the screen was cleared, which is
          needed to clear visible messages. An empty message is also
          never emitted, but clears messages from the message grid.
Solution: Repurpose the "msg_clear" event to be emitted when the screen
          was cleared. Emit an empty message with the `empty` kind to
          hint to a UI to clear the cmdline area.
2025-06-26 22:27:21 +00:00
76de3e2d07 docs(api): document types using LuaCATS types
- Render Lua types in api.txt.

- Added `DictAs(name)` API type which acts the same as `Dict` (no parens)
  when generating the dispatchers, but acts the same as `Dict(name)`
  when generating docs.

- Added `Tuple(...)` API type which is the treated the as `Array` for
  generating the dispatchers, but is used to document richer types.

- Added `Enum(...)` API type to better document enums

- Improve typing of some API functions.

- Improve c_grammar to properly parse API types and replace string pattern
  logic in the parsers.

- Removed all the hardcoded type overrides in gen_eval_files.lua
2025-06-26 13:54:04 +01:00
b40e658717 fix(column): missing redraw with virt_lines_leftcol (#34650)
Problem:  Missing number column redraw with virt_lines_leftcol.
Solution: Set virt_line_index to -1 when skipping a virtual line.
2025-06-26 05:16:19 +00:00
f0757ee590 refactor(ui.c): deduplicate validation logic #34647 2025-06-26 00:15:04 +00:00
4369d7d9a7 fix(ui)!: decouple ext_messages from message grid #27963
Problem:  ext_messages is implemented to mimic the message grid
          implementation w.r.t. scrolling messages, clearing scrolled
          messages, hit-enter-prompts and replacing a previous message.
          Meanwhile, an ext_messages UI may not be implemented in a way
          where these events are wanted. Moreover, correctness of these
          events even assuming a "scrolled message" implementation
          depends on fragile "currently visible messages" global state,
          which already isn't correct after a previous message was
          supposed to have been overwritten (because that should not only
          happen when `msg_scroll == false`).

Solution: - No longer attempt to keep track of the currently visible
            messages: remove the `msg_ext(_history)_visible` variables.
            UIs may remove messages pre-emptively (timer based), or never
            show messages that don't fit a certain area in the first place.
          - No longer emit the `msg(_history)_clear` events to clear
            "scrolled" messages. This opens up the `msg_clear` event to
            be emitted when messages should actually be cleared (e.g.
            when the screen is cleared). May also be useful to emit before
            the first message in an event loop cycle as a hint to the UI
            that it is a new batch of messages (vim._extui currently
            schedules an event to determine that).
          - Set `replace_last` explicitly at the few callsites that want
            this to be set to true to replace an incomplete status message.
          - Don't store a "keep" message to be re-emitted.
2025-06-25 08:25:40 -07:00
5ae41ddde3 feat(prompt): prompt_getinput() gets current input #34491
Problem:
Not easy to get user-input in prompt-buffer before the user submits the
input. Under the current system user/plugin needs to read the buffer
contents, figure out where the prompt is, then extract the text.

Solution:
- Add prompt_getinput().
- Extract prompt text extraction logic to a separate function
2025-06-24 12:42:16 -07:00
efd0fa55c8 fix(cmdline): validate 'incsearch' cursor for "cmdline_show" redraw (#34630)
Problem:  "cmdline_show" event may be emitted with an invalid cursor
          position, causing a redraw that will clear the match highlight.
Solution: Mark the cursor position as valid so that a "cmdline_show"
          callback that updates the screen does not clear the match highlight.
2025-06-24 16:37:51 +02:00
25000be845 fix(prompt): "%" prefix repeated on newlines with formatoptions+=r #34584
Problem:
With `formatoptions+=r`, the prompt prefix "%" is treated as
comment-start (because of global default 'comments' option contains
"%"), so it gets added to the start of the line when a new line
is input in a prompt.

Solution:
Unset the 'comments' option in prompt buffers by default.
2025-06-24 06:52:24 -07:00
5871d26779 fix(autocmd): 'cmdheight' OptionSet with valid window grids (#34619)
Problem:  OptionSet autocmd emitted with invalid grids after entering
          tabpage with different 'cmdheight'.
Solution: First call `tabpage_check_windows()` before changing 'cmdheight'.
          Add a test that exercises the `vim._extui` cmdline.
2025-06-24 10:25:46 +02:00
7f3249fa0d vim-patch:9.1.1476: missing out-of-memory checks in cmdexpand.c (#34624)
Problem:  missing out-of-memory checks in cmdexpand.c
Solution: add missing out-of-memory checks, re-order code
          (John Marriott)

This commit does the following:
- in cmdline_pum_create() add out-of-memory check call of ALLOC_MULT()
- in expand_cmdline() move check for out-of-memory to cover both
  assignments of file_str
- in nextwild() don't free `p2` until after it's last use.

closes: vim/vim#17592

1be5b375c4

N/A patch:
vim-patch:9.1.1474: missing out-of-memory check in mark.c

Co-authored-by: John Marriott <basilisk@internode.on.net>
2025-06-24 07:51:20 +08:00
69c379dc44 fix(quickfix): use correct lnume when appending (#34611)
Problem: ml_get error when updating quickfix buffer with nvim_buf_attach
Solution: use correct lnume parameter in changed_lines for append mode

Fix #34610
2025-06-23 23:48:55 +00:00
fb5a51e775 fix(tui): avoid memory leak and compiler warning on Windows (#34225)
Problem:  On Windows, the value of `term` is overwritten without freeing
          the old allocated value, which may lead to a memory leak.
	  GCC also gives a "incompatible pointer type" warning about
	  passing `*term` to os_tty_guess_term().
Solution: Don't override the old allocated value, and copy the guessed
          value to `term` if its old value is NULL.
2025-06-23 22:07:52 +08:00
a5c55d200b fix(cmd): bar "|" not allowed after :fclose #34613
Problem: `:fclose` command failed when used with trailing `|` bar.
Solution: Add `TRLBAR` flag to fclose command to support trailing bar.
2025-06-23 05:41:31 -07:00
534ec8d447 vim-patch:9.1.1475: completion: regression when "nearest" in 'completeopt' (#34607)
Problem:  completion: regression when "nearest" in 'completeopt'
Solution: fix compare function (Girish Palya)

closes: vim/vim#17577

cd68f21f60

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-06-23 07:56:47 +08:00
ee2fc31b36 vim-patch:9.1.1473: inconsistent range arg for :diffget/diffput (#34588)
Problem:  inconsistent range arg for :diffget/diffput
Solution: fix the range specification, place the cursor for :diffput and
          :diffget consistently on the last line (Yee Cheng Chin)

Previously, `:<range>diffget` only allowed using 1 or above in the range
value, making it impossible to use the command for a diff block at the
beginning of the file. Fix the range specification so the user can now
use 0 to specify the space before the first line. This allows
`:0,$+1diffget` to work to retrieve all the changes from the other file
instead of missing the first diff block. Also do this for `:diffput`.

Also, make `:diffput` work more similar to `:diffget`. Make it so that
if the cursor is on the last line and a new line is inserted in the
other file, doing `:diffput` will select that diff block below the line,
just like `:diffget` would.

Also clean up the logic a little bit for edge cases and for handling
line matched diff blocks better.

closes: vim/vim#17579

d75ab0cbf5

Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2025-06-22 08:00:17 +08:00
0980617c0d build(msvc): suppress msvc build warning for different enum types (#34591)
Problem: Currently our CI is failing due to msvc warning 5287. This
warning tells us that we are performing a binary expression with enums
of two different types. In this case however, this is clearly intended
and valid.

Solution: Suppress warning 5287 on the line this occurs.
2025-06-22 06:54:51 +08:00
fb8dba413f vim-patch:9.1.1467: too many strlen() calls (#34572)
Problem:  too many strlen() calls
Solution: Change expand_env() to return string length
          (John Marriott)

This commit does the following changes:
- In expand_env_esc():
  - return the length of the returned dst string.
  - refactor to remove some calls to STRLEN() and STRCAT()
  - add check for out-of-memory condition.
- Change call sites in various source files to use the return value

closes: vim/vim#17561

fff0132399

Co-authored-by: John Marriott <basilisk@internode.on.net>
2025-06-19 02:21:33 +00:00
8ed6f00ab0 vim-patch:9.1.1471: completion: inconsistent ordering with CTRL-P (#34571)
Problem:  completion: inconsistent ordering with CTRL-P
          (zeertzjq)
Solution: reset compl_curr_match when using CTRL-P (Girish Palya)

fixes: vim/vim#17425
closes: vim/vim#17434

5fbe72edda

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-06-19 09:24:13 +08:00
cb2367a1e2 docs: api, misc 2025-06-18 12:13:55 +02:00
c8e54bf49d docs: deprecate <sfile> 2025-06-18 12:12:23 +02:00
3b85046ed5 fix(messages): "list_cmd" kind for :command, :version (#34529)
Problem:  No ext_messages kind for the :command, :version commands.
          :version is emitted as multiple events.
Solution: Assign them the "list_cmd" kind. Use `msg_put*` to properly
          format the message as a single event.
2025-06-18 07:54:49 +02:00
8af2aea24f Merge pull request #34492 from nenahp/fix-append-cursor
fix: cursor shape don't resume after `:append`
2025-06-18 06:59:05 +08:00
2c9d21f722 fix: cursor shape don't resume after :append
Problem: cursor shape don't resume after `:append`.
e.g. `seq 1000 | nvim --clean +"se gcr+=c:ver25" -`

Solution: emit missing ui event.
2025-06-18 00:40:22 +08:00
286371b4d2 feat(prompt): multiline prompt input #33371
Problem:
Cannot enter multiline prompts in a buftype=prompt buffer.

Solution:
- Support shift+enter (`<s-enter>`) to start a new line in the prompt.
- Pasting multiline text via OS paste, clipboard, "xp, etc.
- A/I in editable region works as usual.
- i/a/A/I outside of editable region moves cursor to end of current
  prompt.
- Support undo/redo in prompt buffer.
- Support o/O in prompt buffer.
- Expose prompt location as `':` mark.
2025-06-17 08:46:57 -07:00
006361fc6b fix(api): buffer updates in quickfix buffer #31105
Problem: Buffer events (specifically on_bytes callbacks) weren't triggered when the
quickfix list was modified, preventing buffer change notifications.

Solution: Add code to send both bytes and lines change notifications after
quickfix buffer updates to properly trigger all attached callbacks.
2025-06-17 06:31:14 -07:00
ae0981070e vim-patch:9.1.1464: gv does not work in operator-pending mode (#34534)
Problem:  gv does not work in operator-pending mode
          (liushapku)
Solution: remove the check for checkclearop in nv_gv_cmd()
          (phanium)

fixes: vim/vim#3666
closes: vim/vim#17551

cb27992cda

Co-authored-by: phanium <91544758+phanen@users.noreply.github.com>
2025-06-17 00:27:41 +00:00
3e984cf02b vim-patch:9.1.1463: Integer overflow in getmarklist() after linewise operation (#34532)
Problem:  Integer overflow in getmarklist() after linewise operation.
Solution: Don't add 1 to MAXCOL (zeertzjq)

related: neovim/neovim#34524
closes: vim/vim#17552

93318a9933
2025-06-16 23:24:52 +00:00
5647b45e69 refactor(generator): use fmt() for string.format() more (#34528) 2025-06-17 06:50:51 +08:00
6ad2a13054 Merge pull request #34495 from bfredl/debwithrelinfo
fix(build): disable problematic marktree assert in RelWithDebInfo builds
2025-06-16 12:27:41 +02:00
576e8f62c2 fix(build): disable problematic marktree assert in RelWithDebInfo builds
Workaround (not a fix) for #27196 and for #33067

Asserts are meant to apply to debug builds but not release
builds for users. However the intermediate RelWithDebInfo
build type is quite often used by end users, so we might
want to disable certain problematic asserts there, while
still preserving them in Debug mode for CI.
2025-06-16 12:03:36 +02:00
b2722181b0 fix(edit): clear showcmd after clearing last put char (#34517)
Problem:  Screen may be updated by a msg_showcmd event before '"' is
          cleared from the screen with register insertion.
Solution: Emit the msg_showcmd event before clearing the '"'.
2025-06-16 11:03:35 +02:00
8cfb993fdf docs: support overloads and async 2025-06-16 09:18:42 +01:00
b92e3889fe vim-patch:631a50c: runtime(doc): mention cannot ignored events in eventignorewin (#34522)
closes: vim/vim#17545

631a50ceb9

Co-authored-by: glepnir <glephunter@gmail.com>
2025-06-16 02:14:20 +00:00
4b2c2eb120 docs(meta): fix incorrect bar -> backtick replacement (#34520) 2025-06-16 09:06:07 +08:00
29f2cb89f0 fix(messages): add append parameter to history entries (#34467)
Problem:  The "append" parameter added in abb40ece is missing from
          history entries, resulting in different message formatting
          for "g<".
Solution: Add "append" field to message history entries.

Co-authored-by: phanium <91544758+phanen@users.noreply.github.com>
2025-06-15 23:36:41 +02:00
5046ef4c8f fix(extui): clear cmdline buffer for first message (#34490)
Problem:  Cmdline buffer is not cleared for a new message (since c973c7ae),
          resulting in an incorrect spill indicator. When the cmdline
          buffer is cleared, "msg_row" is not invalidated, resulting in
          an error. The extui module is untested.
          Return value of `vim.ui_attach()->callback` is undocumented.
Solution: Clear the cmdline buffer for the first message in an event
          loop iteration. Ensure msg_row passed as end_row does not
          exceed buffer length.
          Add `messages_spec2.lua` to test the extui module, keeping in
          mind that test coverage will greatly increase if this UI is made
          the default. As such, only tests for specific extui functionality
          unlikely to be covered by tests leveraging the current message grid.
          Document the return value of `vim.ui_attach()->callback`, it seems
          to make sense, and is also used to suppress remote UI events in
          `messages_spec2.lua`.
2025-06-15 12:55:01 +02:00
0d658660c2 fix(window): don't enter unfocusable or hidden prevwin (#34486)
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-06-14 23:42:23 +02:00
c7f38e3bc8 fix(api): nvim_parse_cmd parses :map incorrectly #34068
Problem: nvim_parse_cmd() incorrectly splits mapping commands like
into three arguments instead of preserving whitespace in the RHS.

Solution: Add special handling for mapping commands to parse them as exactly
two arguments - the LHS and the RHS with all whitespace preserved.
2025-06-14 10:17:56 -07:00
4367441213 docs: misc
Co-authored-by: Jan Weinkauff <jan@weinkauff.cloud>
Co-authored-by: MeanderingProgrammer <meanderingprogrammer@gmail.com>
Co-authored-by: Yochem van Rosmalen <git@yochem.nl>
Co-authored-by: phanium <91544758+phanen@users.noreply.github.com>
2025-06-14 17:24:36 +02:00
8001276bd0 docs: vim.fs., diagnostics, lsp #34402 2025-06-13 07:49:21 -07:00
3e30323135 fix(coverity/554963): preallocate msg.items to avoid FORWARD_NULL #34484
*** CID 554963:           (FORWARD_NULL)
/src/nvim/memline.c: 3484             in findswapname()
3478                 if (swap_exists_action != SEA_NONE) {
3479                   kv_printf(msg, _("Swap file \""));
3480                   kv_printf(msg, "%s", fhname);
3481                   kv_printf(msg, _("\" already exists!"));
3482                   char *run_but = _("&Open Read-Only\n&Edit anyway\n&Recover\n&Quit\n&Abort");
3483                   char *but = _("&Open Read-Only\n&Edit anyway\n&Recover\n&Delete it\n&Quit\n&Abort");
>>>     CID 554963:           (FORWARD_NULL)
>>>     Passing null pointer "msg.items" to "do_dialog", which dereferences it.
3484                   choice = (sea_choice_T)do_dialog(VIM_WARNING, _("VIM - ATTENTION"), msg.items,
3485                                                    proc_running ? run_but : but, 1, NULL, false);
3486
3487                   // compensate for missing "Delete it" button
3488                   choice += proc_running && choice >= 4;
3489                   // pretend screen didn't scroll, need redraw anyway
/src/nvim/memline.c: 3492             in findswapname()
3486
3487                   // compensate for missing "Delete it" button
3488                   choice += proc_running && choice >= 4;
3489                   // pretend screen didn't scroll, need redraw anyway
3490                   msg_reset_scroll();
3491                 } else {
>>>     CID 554963:           (FORWARD_NULL)
>>>     Passing null pointer "msg.items" to "msg_outtrans", which dereferences it.
3492                   msg_outtrans(msg.items, 0, false);
3493                 }
3494                 no_wait_return--;
3495                 kv_destroy(msg);
3496                 xfree(fhname);
3497               }
2025-06-13 05:19:30 -07:00