19134 Commits

Author SHA1 Message Date
29c8dabd41 fix(insexpand): update showmode when updating the screen (#34466)
Problem:  Eagerly calling `showmode()` to update showmode where setting
          `redraw_showmode` to be updated later would suffice.
Solution: Set `redraw_showmode` instead of calling `showmode()` if not
          showing a busy message followed by a `ui_flush()`.
2025-06-13 10:37:19 +02:00
90b682891d vim-patch:91af4c4: runtime(doc): improve the wording of 'sts', 'varts' and 'varsts' values (#34480)
closes: vim/vim#17522

91af4c4180

Co-authored-by: Damien Lejay <damien@lejay.be>
Co-authored-by: Christian Brabandt <cb@256bit.org>
2025-06-13 00:53:48 +00:00
d86d4bacc1 fix(messages): make swapfile attention message part of prompt (#34414)
Problem:  The swapfile attention message is not repeated after clearing
          the screen.
          After clearing the screen `msg_scrolled` is reset without
          clearing other related variables, causing an assert.
Solution: Make the attention message part of the confirm prompt.
          Call `msg_reset_scroll()`.
2025-06-12 11:57:17 +02:00
b8ee354f12 fix(msgpack): flush incomplete big UI event before packing RPC event
This might happen, e.g. if we send a fast RPC reply in a os_breakcheck()
in the middle of redrawing and big ui_ext events are produced.

fixes #31316
2025-06-12 11:05:38 +02:00
dc05598d02 fix(cmdline): set search cursor after ui_flush() (#34418)
Problem:  vim.ui_attach cmdline events emitted with an ephemeral cursor
          position that is only used as the start of the search.
Solution: Delay setting the cursor position until after ui_flush().
2025-06-12 08:53:10 +02:00
66e4784f5a fix(float): ensure relative window grid is allocated (#34459)
Problem:  Uninitialized grid for a "win" relative float when redrawing
          just after it has been opened.
Solution: Ensure window grid is allocated or assigned the default grid.
2025-06-12 08:51:29 +02:00
47df8f5a4b vim-patch:053aee0: runtime(doc): add more pointers to 'completeopt' (#34460)
Before this commit, I had trouble finding information about configuring
the insert mode completion. In particular, it was not clear that the
'wildopt' config that I already had in my vimrc does not apply here.

Also, `insert.txt` barely mentioned 'completeopt' except when
describing popups (I was more interested in bash-like behavior
where the unique prefix of all completions is completed first).

I'm hoping these edits will make the relevant docs easier to find.

closes: vim/vim#17515

053aee01f7

Co-authored-by: Ilya Grigoriev <ilyagr@users.noreply.github.com>
2025-06-12 07:32:07 +08:00
6bee2f686f fix(shada): prevent use-after-free when mapping file marks (#34446)
Problem: When ignore_buf skips buffers during initialization,
shada_read_when_writing uses entry.data.filemark.fname directly
as map key, but later frees the entry, leaving dangling pointers.

Solution: Always create independent copies of filenames as map keys
using xstrdup() for new items, and free all keys during cleanup.

Fix #34440
2025-06-11 22:31:48 +00:00
6a71239cd5 fix(terminal): don't disable scrolloff for non-terminal buffers (#34451) 2025-06-11 14:47:06 +00:00
de87ceb3be feat(tui): support APC queries in TermResponse (#34426)
Add support for APC sequences to libtermkey and the TermResponse
autocommand event.
2025-06-11 08:26:58 -05:00
1abcd9fe28 vim-patch:9.1.1452: completion: redundant check for completion flags (#34434)
Problem:  completion: redundant check for completion flags
Solution: refactor code slightly (glepnir)

refactor: nest fuzzy completion logic to avoid duplicate flag checks

- Combine COT_FUZZY checks into single nested condition
- Reduce redundant bitwise operations in ins_compl_new_leader()

closes: vim/vim#17494

ecf8f15884

Co-authored-by: glepnir <glephunter@gmail.com>
2025-06-11 00:06:48 +00:00
79ce71430f vim-patch:bfa1636: runtime(doc): update documentation on tabstop settings (#34433)
Unify the treatment of tabstop, correct errors and deprecate smarttab
usage.

closes: vim/vim#17444

bfa16364f1

Co-authored-by: Damien Lejay <damien@lejay.be>
2025-06-10 23:53:35 +00:00
612f8e7c9e vim-patch:9.1.1450: Session has wrong arglist with :tcd and :arglocal (#34430)
Problem:  Session has wrong arglist with :tcd and :arglocal.
Solution: Also use absolute path for :argadd when there is tabpage-local
          directory (zeertzjq).

related: neovim/neovim#34405
closes: vim/vim#17503

a304e49790
2025-06-10 23:35:42 +00:00
5075043823 vim-patch:9.1.1449: typo in pum_display()
Problem:  typo in pum_display()
Solution: update the comment, remove empty new lines
          (glepnir)

closes: vim/vim#17506

ed4eb74f7a

Co-authored-by: glepnir <glephunter@gmail.com>
2025-06-11 06:42:32 +08:00
ac772706cc vim-patch:9.1.1447: completion: crash when backspacing with fuzzy completion
Problem:  completion: crash when backspacing with fuzzy completion
Solution: Don't dereference compl_first_match when it's NULL
          (zeertzjq).

related: neovim/neovim#34419
closes: vim/vim#17511

91782b4aeb
2025-06-11 06:42:28 +08:00
b5aef05b8f fix(terminal): fix OSC 8 parsing (#34424)
vterm does not send us the terminator in the string fragment. Our OSC 8
parser assumed that it was and therefore treated short strings as
invalid (as it assumed it was missing a terminator).
2025-06-10 15:52:45 -05:00
2dba5abcb2 fix(tui): wait for embedded server's exit code
Uses the undocumented "error_exit" UI event for a different purpose:
When :detach is used on the server, send an "error_exit" with 0 `status`
to indicate that the server shouldn't wait for client exit.
2025-06-10 23:00:21 +08:00
b98eefd803 fix(shada): prevent 'nobuflisted' buffers in v:oldfiles #34373
Problem: 'nobuflisted' buffers are incorrectly added to v:oldfiles.

Solution: Use ignore_buf() consistently in shada_write() for buffer
marks processing.
2025-06-10 06:50:16 -07:00
bcba067dc2 vim-patch:9.1.1445: negative matchfuzzy scores although there is a match (#34409)
Problem:  negative matchfuzzy scores although there is a match
          (Maxim Kim)
Solution: reset the score if a match has been found but the score is
          negative (Girish Palya)

The fuzzy algorithm may miss some matches in long strings due to recursion
limits. As a result, the score can end up negative even when matches exist.
In such cases, reset the score to ensure it is non-negative.

fixes: #vim/vim#17449
closes: vim/vim#17469

328332b0b0

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-06-10 00:47:14 +00:00
7a58cf4b96 vim-patch:9.1.1443: potential buffer underflow in insertchar() (#34408)
Problem:  potential buffer underflow in insertchar()
Solution: verify that end_len is larger than zero
          (jinyaoguo)

When parsing the end-comment leader, end_len can be zero if
copy_option_part() writes no characters. The existing check
unconditionally accessed lead_end[end_len-1], causing potential
underflow when end_len == 0.

This change adds an end_len > 0 guard to ensure we only index lead_end
if there is at least one character.

closes: vim/vim#17476

82a96e3dc0

Co-authored-by: jinyaoguo <guo846@purdue.edu>
2025-06-10 08:20:55 +08:00
72f4bb9ae8 vim-patch:9.1.1444: Unused assignment in set_fuzzy_score()
Problem:  Unused assignment in set_fuzzy_score() (after 9.1.1441).
Solution: Remove it (zeertzjq).

closes: vim/vim#17472

de1c7ac432
2025-06-10 07:27:55 +08:00
bcfc22853a vim-patch:9.1.1441: completion: code can be improved
Problem:  completion: code can be improved
Solution: remove reposition_match() and use mergesort_list(),
          for fuzzy completion, sort by fuzzy score immediately after
          setting a new leader (Girish Palya)

closes: vim/vim#17460

b8ee1cf56e

Co-authored-by: Girish Palya <girishji@gmail.com>
Co-authored-by: glepnir <glephunter@gmail.com>
2025-06-10 07:27:09 +08:00
a5f236291c fix(messages): single event for multi-expr :echo (#34393)
Problem:  Separate "msg_show" event for each expression in a multi-expr
          :echo(n) command.
Solution: Only set the kind when `atstart == true`.
2025-06-09 18:58:31 +02:00
e876a739ee fix(messages): recognize cmdline one_key/number prompt State (#34206)
Problem:  Since 48e2a736, prompt messages are handled by an actual
          active cmdline, resulting in `State` no longer being equal
          to `MODE_CONFIRM` which is used in some places. E.g. to
          specify the current `mode()` or to re-emit a confirm message.
Solution: Replace `MODE_CONFIRM` with a new `MODE_CMDLINE` sub-mode when
          `ccline.one_key/mouse_used` is set. Use it to avoid clearing
          mouse_used prompt messages, and to re-emit one_key messages
          (when ext_messages is inactive, for which this is unnecessary).
2025-06-09 18:57:28 +02:00
336b46a879 fix(highlight): preserve background transparency in 'winblend' #34302
Problem: When using 'winblend', transparent backgrounds (-1) are forced
to default colors (usually black) during attribute blending, breaking
the transparency effect.

Solution: Check original background colors before blending in
hl_blend_attrs(). If both background and foreground originally had
transparent backgrounds, preserve transparency instead of forcing
default colors.
2025-06-09 08:24:46 -07:00
76d0206342 fix(api): count parameter in nvim_parse_cmd, nvim_cmd #34253
Problem:
- nvim_parse_cmd('copen', {}) returns count: 0, causing nvim_cmd to override default behavior
- nvim_cmd({cmd = 'copen', args = {10}}, {}) fails with "Wrong number of arguments"

Solution:
- Only include count field in parse result when explicitly provided or non-zero
- Interpret single numeric argument as count for count-only commands like copen
2025-06-09 06:50:26 -07:00
6f632a8615 fix(compositor): don't blend uninitialized background cells #34364
Problem:  A 'winblend' window floating over uninitialized cells loses
          its highlighting.

Solution: Return the front attribute for uninitialized background cells.
2025-06-09 05:43:33 -07:00
680d3770b1 refactor(shada): replace macros taking macros and code fragments
I guess these kinds of DRY techniques are kinda cutesy but unfortunately
I cannot expand macros invoking macros with various kind of syntax
fragments and back-references to local variables, at the same time
as I try to understand what is actually going on when you :wshada or :rshada
your jump marks, some of which having fname:s in them and some not.

This replaces it with four spelled out loops, although it is fine to
keep the memmove() related code generic in the item size just by passing a
runtime parameter (we have generics at home). Galaxy brain -03 -flto compilers
are gonna inline it anyway if it is worth it.
2025-06-09 09:33:20 +02:00
d2dad30898 vim-patch:9.1.1439: Last diff folds not merged (#34380)
Problem:  Last diff folds not merged (after v8.1.1922)
Solution: loop over all windows in the current tabpage and update all
          folds (Gary Johnson)

This commit fixes a bug where the last two folds of a diff are not
merged when the last difference between the two diff'd buffers is
resolved.

Normally, when two buffers are diff'd, folding is used to show only the
text that differs and to hide the text that is the same between the two
buffers.  When a difference is resolved by making a block of text the
same in both buffers, the folds are updated to merge that block with the
folds above and below it into one closed fold.

That updating of the folds did not occur when the block of text was the
last diff block in the buffers.

The bug was introduced by this patch on August 24, 2019:

    patch 8.1.1922: in diff mode global operations can be very slow

    Problem:    In diff mode global operations can be very slow.
    Solution:   Do not call diff_redraw() many times, call it once when
		redrawing.  And also don't update folds multiple times.

Unfortunately, folds were then not updated often enough.

The problem was fixed by adding a short loop to the ex_diffgetput()
function in diff.c to update all the folds in the current tab when the
last difference is removed.

A test for this was added to test_diffmode.vim.  Two of the reference
screen dumps for another test in that file,
Test_diffget_diffput_linematch(), had to be changed to have all the
folds closed rather than to have the last diff block remain open.

closes: vim/vim#17457

3fa0d3514b

Co-authored-by: Gary Johnson <garyjohn@spocom.com>
2025-06-09 06:57:54 +08:00
2b79d9ba1a vim-patch:9.1.1437: MS-Windows: internal compile error in uc_list() (#34379)
Problem:  MS-Windows: internal compile error in uc_list() with VS 17.14
          (ibear)
Solution: refactor code slightly (Mike Williams)

fixes: vim/vim#17402
closes: vim/vim#17464

0174d8f386

Co-authored-by: Mike Williams <mrmrdubya@gmail.com>
2025-06-09 06:57:31 +08:00
00bec1fd90 vim-patch:partial:8f7256a (#34368)
vim-patch:partial:8f7256a: runtime(doc): fix some style issues and remove obsolete docs

8f7256a5ee

Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
2025-06-08 09:59:02 +08:00
52c61d9690 feat: make :restart work for remote UI (#34354) 2025-06-07 22:10:34 +00:00
96a0e5f265 docs: lua, UI events #34261 2025-06-07 07:49:04 -07:00
c8c78b531b fix(startup): make startup windows if there are only floating windows (#34349)
Problem:  If user init creates a floating window, startup windows
          (e.g. to accomodate arglist files) are no longer created.
Solution: Check that firstwin->w_next is not floating when deciding
          whether to make startup windows.
2025-06-07 11:24:51 +02:00
af82f36108 fix(api): update topline when flushing with nvim__redraw() (#34346)
Problem:  nvim__redraw may update the screen with an invalid topline.
Solution: Update the topline before calling `update_screen()` (as
          :redraw does).
2025-06-07 11:24:24 +02:00
bf1d4e9793 fix(messages): capture execute("messages") with ext_messages (#34342)
Problem:  "msg_history_show" event is emitted when `msg_silent > 0`.
          E.g. when capturing its output with `execute()`, which also
          doesn't work with ext_messages.
Solution: Don't emit the "msg_history_show" event when `msg_silent > 0`.
          Call regular messaging functions when `redirecting()`, to
          execute `redir_write()` while ensuring the message itself
          is not emitted.
2025-06-06 16:45:30 +02:00
3b6084ddf4 fix: type fixes
Type fixes caught by emmylua
2025-06-06 15:36:48 +01:00
99e6294819 fix(treesitter): ensure TSNode's tree is immutable
Problem:

TSNode contains a `const TSTree*` and a `const void *id`. The `id`
points to Tree-sitter's internal type `Subtree`, which resides inside
the `TSTree` but may be deallocated if the `TSTree` is mutated (which
is likely why it is `const`).

The Lua method `TSTree:edit()` mutates the tree, which can deallocate
`id`.

See #25254 and #31758.

Solution:

To avoid this, we now make a copy of the tree before pushing its root to
the Lua stack. This also removes the fenv from TSLuaTree, as it was only
used when pushing the tree root to the Lua stack.

We also copy the tree in `node_tree`.

`ts_tree_copy()` just increments a couple of reference counters, so it's
relatively cheap to call.
2025-06-06 15:35:52 +01:00
3165e94a64 fix(api): ensure win_get_config() "border" is reciprocal (#34322)
fix(api): ensure win_get_config() is reciprocal

Problem:  win_get_config() does not include a 'none' border field,
          causing nvim_open_win() to apply the 'winborder' value.
Solution: Include a 'none' border field in the returned config,
          such that it can be used reciprocally in nvim_open_win()
          to yield the same window layout.
2025-06-06 12:40:57 +02:00
9f505b4d0f refactor: make two functions used only in memory.c static (#34339)
After #29450 try_to_free_memory() is only used in memory.c.
Also move do_outofmem_msg() closer to where it's used.
2025-06-06 13:49:22 +08:00
60d0b7d0c3 fix(diff): fix incorrect item size of dout_ga (#34338)
Related 267494151b
2025-06-06 04:34:28 +00:00
552983515f vim-patch:9.1.1435: completion: various flaws in fuzzy completion (#34335)
Problem:  completion: various flaws in fuzzy completion
Solution: fix the issues (Girish Palya)

- Remove the brittle `qsort()` on `compl_match_array`.
- Add a stable, non-recursive `mergesort` for the internal doubly
  linked list of matches.
- The sort now happens directly on the internal representation (`compl_T`),
  preserving sync with external structures and making sorting stable.
- Update fuzzy match logic to enforce `max_matches` limits after
  sorting.
- Remove `trim_compl_match_array()`, which is no longer necessary.
- Fixe test failures by correctly setting `selected` index and
  maintaining match consistency.
- Introduce `mergesort_list()` in `misc2.c`, which operates generically
  over doubly linked lists.
- Remove `pum_score` and `pum_idx` variables

fixes: vim/vim#17387
closes: vim/vim#17430

8cd42a58b4

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-06-06 02:46:01 +00:00
6171ab7f4e vim-patch:9.1.1433: Unnecessary :if when writing session
Problem:  Unnecessary :if in session where both branches have the same
          effect (after 9.1.1431).
Solution: Remove the superfluous :if (zeertzjq).

closes: vim/vim#17448

8f751d56f4
2025-06-06 06:37:36 +08:00
f89381e05c vim-patch:9.1.1431: Hit-Enter Prompt when loading session files
Problem:  Hit-Enter Prompt when loading session files
Solution: use set+= for 'shortmess' to keep the existing flags
          (Miguel Barro)

closes: vim/vim#17445

0ca5966196

Co-authored-by: Miguel Barro <miguel.barro@live.com>
2025-06-06 06:36:47 +08:00
5e470c7af5 fix(menu): fix listing of submenus (#34315)
Problem:  Listing submenus with :menu doesn't work.
Solution: Don't go to the parent of the return value of find_menu(), and
          handle empty path at the caller.

Related #8194, which actually only fixed the problem for menu_get(), not
for :menu Ex command.
2025-06-05 01:18:00 +00:00
038fb30ece vim-patch:d6c9ac9: runtime(doc): clarify the effect of 'smarttab'
closes: vim/vim#17426

d6c9ac97a0

Co-authored-by: Damien Lejay <damien@lejay.be>
2025-06-05 06:31:09 +08:00
f577bb024e docs: getreg() type #34215
```lua
---@type string
local _a = vim.fn.getreg('a', 1)

---@type string[]
local _b = vim.fn.getreg('a', 1, 1)
```
2025-06-04 09:26:56 -07:00
7e393ff4f2 refactor(windows): redundant icon messages #34274
Problem:  Two separate window messages are used to get
          the original console icon and set a new
          one on windows, although the `WM_SETICON`
          message returns the original icon itself.

Solution: Replace the two `WM_GETICON` messages with
          two `WM_SETICON` messages, save the return
          values and remove the call to `os_icon_set`.
          Also, replace `os_icon_set` with `os_icon_reset`
          as its only usage is now resetting the
          icon to the original one.
2025-06-04 07:11:01 -07:00
dd9ac565d8 Merge pull request #34294 from glepnir/vim-9.1.1426
vim-patch:9.1.{1426,1428}: register completion improve
2025-06-04 13:46:19 +08:00
97ca92f9dd vim-patch:9.1.1428: completion: register completion needs cleanup
Problem:  completion: register completion needs cleanup
Solution: slightly refactor get_register_completion()
          (glepnir)

closes: vim/vim#17432

86d46a7018

Co-authored-by: glepnir <glephunter@gmail.com>
2025-06-04 13:27:38 +08:00