Commit Graph

33667 Commits

Author SHA1 Message Date
zeertzjq
443278c587 refactor: rename ga_concat_strings_sep() to ga_concat_strings() (#35498)
This adds a missing change from Vim patch 7.4.279.

N/A patch:
vim-patch:9.1.1691: over-allocation in ga_concat_strings()
2025-08-27 10:17:12 +08:00
zeertzjq
4263ec21c2 vim-patch:9.1.1688: potential buffer overrun in bufwrite.c (#35497)
Problem:  potential buffer overrun in bufwrite.c
Solution: Use a temporary variable (John Marriott)

In my Windows 11 Pro 64-bit build MAXPATHL is 1024 and IOSIZE is 1025.
In my Archlinux Linux 64-bit build MAXPATHL is 4096 and IOSIZE is 1025.

In funuction buf_write():
There is a check (line 713) that makes sure the length of fname is less
than MAXPATHL. There is a call to STRCPY() (line 1208) which copies the
string at fname into IObuff (which has size IOSIZE). For Unix builds
fname is set to sfname which may or may not be shorter. However, if
sfname is NULL sfname is set to fname.

Therefore, in builds where MAXPATHL > IOSIZE (eg in my linux build), it
is theoretically possible for the STRCPY() call to exceed the bounds of
IObuff.

This PR addresses this by copying fname into a local variable that has
the same maximum size as fname.

In addition:
Given that the filename is unconditionally overwritten in the for loop,
only copy the directory portion of fname. Move variable i closer to
where it is used.

closes: vim/vim#18095

a19b019b87

Co-authored-by: John Marriott <basilisk@internode.on.net>
2025-08-27 10:16:59 +08:00
zeertzjq
c741927883 vim-patch:9.1.1689: CmdlineChanged not triggered by <Del> (#35496)
Problem:  CmdlineChanged not triggered by <Del>
Solution: Use STRCMP() instead of STRNCMP()
          (Shougo Matsushita)

closes: vim/vim#18101

540480697d

Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
2025-08-27 10:16:44 +08:00
zeertzjq
8f78591f9a fix(column): wrong alignment and highlight with empty 'display' (#35495)
This fixes a regression from #26961.
2025-08-27 10:16:13 +08:00
Shadman
8b171852a9 feat(api): nvim_echo can emit Progress messages/events #34846
Problem:
Nvim does not have a core concept for indicating "progress" of
long-running tasks. The LspProgress event is specific to LSP.

Solution:
- `nvim_echo` can emit `kind="progress"` messages.
  - Emits a `Progress` event.
  - Includes new fields (id, status, percent) in the `msg_show` ui-event.
  - The UI is expected to overwrite any message having the same id.
- Messages have a globally unique ID.
  - `nvim_echo` returns the message ID.
- `nvim_echo(… {id=…})` updates existing messages.

Example:

    local grp = vim.api.nvim_create_augroup("Msg", {clear = true})
    vim.api.nvim_create_autocmd('Progress', {
      pattern={"term"},
      group = grp,
      callback = function(ev)
        print(string.format('event fired: %s', vim.inspect(ev))..'\n')
      end
    })

    -- require('vim._extui').enable({enable=true, msg={target='msg', timeout=1000}})
    vim.api.nvim_echo({{'searching'}}, true, {kind='progress',  percent=80, status='running', title="terminal(ripgrep)"})
    local id = vim.api.nvim_echo({{'searching'}}, true, {kind='progress', status='running', percent=10, title="terminal(ripgrep)"})
    vim.api.nvim_echo({}, true, {id = id, kind='progress', percent=20, status = 'running', title='find tests'})
    vim.api.nvim_echo({}, true, {id = id, kind='progress', status='running', percent=70})
    vim.api.nvim_echo({{'complete'}}, true, {id = id, kind='progress', status='success', percent=100, title="find tests"})

Followups:
- Integrate with 'statusline' by listening to the Progress autocmd event.
- Integrate progress ui-event with `vim._extui`.
2025-08-26 13:48:53 -07:00
Sean Dewar
1e1619de83 fix(eval): winnrs of unfocusable/hidden windows #35474
Problem: various functions may return incorrect window numbers for unfocusable
or hidden windows.

Solution: fix the checks. Make sure current windows in non-current tabpages have
a window number.

Fixes #35453
2025-08-26 13:13:05 -07:00
Sean Dewar
6a409e0507 fix(terminal): don't trigger TextChangedT for unrelated redraws
Problem: TextChangedT fires depending on whether Nvim needs to update_screen
while in terminal mode. This makes little sense as redraws can be completely
unrelated to the terminal. Also, TextChanged could be fired from changes in
terminal mode after returning to normal mode.

Solution: trigger it when b:changedtick changes, like other such events. Happens
when invalid cells are refreshed, though is no longer affected by cursor
changes. Don't fire TextChanged from changes in terminal mode after leaving.

Unlike the other TextChanged* events, I've elected to not have it be influenced
by typeahead. Plus, unlike when leaving insert mode when no TextChangedI events
are defined, I don't trigger TextChanged when returning to normal mode from
changes in terminal mode (is that a Vim bug?)

Curiously, Vim's TextChangedT is different; it's tied to its terminal cursor
redraws, which triggers pretty eagerly (but is unaffected by unrelated redraws)
- usually *twice* when data is sent to the terminal (regardless of whether it
causes any visible changes, like incomplete escape codes; wasn't true for Nvim).

Not clear to me how this event was actually intended to work, but this seems to
make the most sense to me.
2025-08-26 09:49:12 +01:00
Sean Dewar
e6ba78919c fix(terminal): possibly wrong wrow/wcol in active terminal
Problem: w_wrow/col calculation in terminal_check_cursor is wrong when the
terminal is smaller than the window. Common when there's a larger window open
with the same terminal, or just after a resize (as refresh_size is deferred).

Solution: don't calculate it; validate_cursor will correct it later if it's
out-of-date.

Note that the toplines set for the terminal (also before this PR) assume
'nowrap' (which is set by default for terminal windows), and that no weird stuff
like filler lines are around. That means, for example, it's possible for the
cursor to be moved off-screen if there's wrapped lines. If this happens, it's
likely update_topline will move the cursor back on screen via validate_cursor or
similar, but maybe this should be handled more elegantly in the future?
2025-08-26 09:49:12 +01:00
Sean Dewar
c845f1923d fix(terminal): patch various autocommand-related holes
Problem: autocommands can cause various problems in terminal mode, which can
lead to crashes, for example.

Solution: fix found issues. Move some checks to terminal_check and guard against
autocommands messing with things. Trigger TermEnter/Leave after terminal mode
has changed/restored most state. Wipeout the correct buffer if TermLeave
switches buffers and fix a UAF if it or WinScrolled/Resized frees the terminal
prematurely.

These changes also allow us to remove the buffer restrictions on TextChangedT;
they were inadequate in stopping some issues, and WinScrolled/Resized was
lacking them anyway.
2025-08-26 09:49:12 +01:00
Sean Dewar
b7124ae768 fix(terminal): update winopts and focus when switching terminals
Problem: window options and terminal focus notifications not updated when
switching terminals without leaving terminal mode.

Solution: update them.
2025-08-26 09:49:12 +01:00
Sean Dewar
d07cbb2f42 fix(terminal): check size when creating new tabpage
Problem: when creating a new tabpage with a terminal window, terminal size is
not updated if there is no statusline.

Solution: do not rely on last_status to implicitly call terminal_check_size as a
side effect of making room for a statusline; call it directly.
2025-08-26 09:49:12 +01:00
Sean Dewar
61217e3618 fix(terminal): avoid events messing up topline of focused terminal
Problem: topline of a focused terminal window may not tail to terminal output if
events scroll the window.

Solution: set the topline in terminal_check_cursor.
2025-08-26 09:49:12 +01:00
Sean Dewar
ad1dfc92a0 fix(terminal): add various missing redraws
Problem: missing redraws when restoring saved cursorline/column, plus missing
statusline and mode redraws when not updating the screen in terminal mode.

Solution: schedule the redraws in a similar manner to other modes and remove
some now unnecessary redrawing logic. Redraw if cursorline-related options
change from entering terminal mode. This fixes test failures in later commits.

WTF: TextChangedT triggers based on must_redraw, which is... fun...? Try to
preserve its behaviour as much as we can for now.
2025-08-26 09:49:12 +01:00
Sean Dewar
5e521c3b5a fix(terminal): avoid tailed cursor in focused terminal in events
Problem: in terminal mode, adjust_topline moves curwin's cursor to the last row
so set_topline tails the non-scrollback area. This may result in the observed
cursor position remaining tailed in events within the focused terminal, rather
than reflecting the actual cursor position.

Solution: use the focused terminal's actual cursor position immediately, rather
than relying on the next terminal_check_cursor call in terminal_check to set it.

Note: Maybe also possible for terminal mode cursor position to be stale
(reporting the normal mode position) when switching buffers in events to another
terminal until the next terminal_check call? (or until refresh_terminal is
called for it) Maybe not worth fixing that, though.
2025-08-26 09:49:12 +01:00
Jan Edmund Lazo
088ba835ed vim-patch:8.2.0845: text properties crossing lines not handled correctly (#35483)
Problem:    Text properties crossing lines not handled correctly.
Solution:   When joining lines merge text properties if possible.
            (Axel Forsman, closes vim/vim#5839, closes vim/vim#5683)

87be9be1db

Port docs from patch v8.1.0688.
Rewrite docs for ml_replace_buf_len().

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-08-26 12:54:13 +08:00
zeertzjq
821bfc02fb vim-patch:9.1.1685: Missing changes from PR 18068 (#35482)
Problem:  Missing changes from PR 18068
Solution: Include the missing changes
          (Girish Palya)

c6a0f42cdb

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-08-26 07:24:21 +08:00
zeertzjq
516363e6ba test: increase timeout in 'autocompletedelay' test (#35467)
Change timeout from 200ms to 400ms, which is still 100ms lower than the
'autocompletedelay' value.
2025-08-25 15:33:54 +08:00
Jan Edmund Lazo
5f3d00a5a6 vim-patch:8.1.2371: FEAT_TEXT_PROP is a confusing name (#35466)
Problem:    FEAT_TEXT_PROP is a confusing name.
Solution:   Use FEAT_PROP_POPUP. (Naruhiko Nishino, closes vim/vim#5291)

05ad5ff0ab

textprop,popuwin remain N/A features.
getchar.c has the relevant code changes.

Port runtest.vim changes from patch v8.1.1561.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-08-25 15:16:16 +08:00
Justin M. Keyes
58060c2340 Merge #33972 feat(lsp): textDocument/inlineCompletion 2025-08-24 22:17:34 -04:00
Yi Ming
42f244bf18 fix(lsp): check whether buffer is valid when scheduled #35461 2025-08-24 18:59:56 -07:00
Yi Ming
0e70aa0e86 feat(lsp): support textDocument/inlineCompletion 2025-08-25 09:48:27 +08:00
Justin M. Keyes
bccec33f5a docs: misc #35459 2025-08-24 23:43:48 +00:00
zeertzjq
b2a136bd67 Merge pull request #35445 from janlazo/vim-9.1.0546
vim-patch:8.1.{579,654,655},9.1.0546
2025-08-25 07:36:59 +08:00
Maria José Solano
1f63735f17 fix(lsp): treat nil inlay hint result as empty array (#35458)
`gopls` seems to send a nil result when there are no inlay hints for the
buffer. [The protocol](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_inlayHint)
allows for the server to send an array or nil, and it isn't clear what
nil should represent. I think it's reasonable to treat it as an empty
array though.
2025-08-24 15:46:08 -07:00
Jan Edmund Lazo
76729a2044 vim-patch:8.1.0655: when appending a line text property flags are not added
Problem:    When appending a line text property flags are not added.
Solution:   Add text properties to a newly added line.

b56ac049ea

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-08-24 18:43:18 -04:00
Jan Edmund Lazo
b5e20d7dff vim-patch:8.1.0654: when deleting a line text property flags are not adjusted
Problem:    When deleting a line text property flags are not adjusted.
Solution:   Adjust text property flags in preceding and following lines.

c1a9bc1a72

"textprop" feature remains N/A.
Porting to sync ml_delete_int() with Vim 8.2.0845 and later.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-08-24 11:00:01 -04:00
Jan Edmund Lazo
5a14a2679d vim-patch:8.1.0579: cannot attach properties to text
Problem:    Cannot attach properties to text.
Solution:   First part of adding text properties.

98aefe7c32

"textprop" feature remains N/A.
Porting for ml_replace_len().

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-08-24 10:56:05 -04:00
Yi Ming
40f5115ac4 fix(lua): disable strict_indexing when converting LSP positions 2025-08-24 21:02:02 +08:00
zeertzjq
6018aed92f Merge pull request #35454 from zeertzjq/vim-f66674c
vim-patch: runtime file updates
2025-08-24 20:40:06 +08:00
zeertzjq
98407a8b91 vim-patch:99964e2: runtime(python): support 'type's soft keyword form
`type` became a soft keyword in Python 3.12. In that form, it is a
statement that declares a type alias:

    # type_stmt ::= 'type' identifier [type_params] "=" expression
    type Point = tuple[float, float]

To implement support for this, this change does three things:

1. adds a `pythonType` group (linked to `Type`)
2. matches `type` followed by an identifier as `pythonStatement`
3. continues to match `type` in other forms as `pythonBuiltin`

Ref:
- https://docs.python.org/3/reference/lexical_analysis.html#soft-keywords
- https://docs.python.org/3/reference/simple_stmts.html#the-type-statement

closes: vim/vim#18090

99964e2ea7

Co-authored-by: Jon Parise <jon@indelible.org>
2025-08-24 20:09:33 +08:00
zeertzjq
e12eca77ee vim-patch:e06d81f: runtime(sh): add syntax highlighting support for ${ cmd;} and ${|cmd;}
bash 5.3 (released July 2025) added support for ${ cmd;} and
${|cmd;} style command substitution, which is similar (but not
identical) to ksh/mksh.

closes: vim/vim#18084

e06d81fe67

Co-authored-by: Kevin Pulo <kevin.pulo@mongodb.com>
2025-08-24 20:09:02 +08:00
zeertzjq
53802da38b vim-patch:f66674c: runtime(fstab): Added mtab support to fstab syntax.
closes: vim/vim#18074

f66674cf42

Co-authored-by: Radu Dineiu <radu.dineiu@gmail.com>
2025-08-24 20:08:15 +08:00
Yi Ming
62b45b8fe4 feat(lua): conversion between extmark positions 2025-08-24 19:38:38 +08:00
Yi Ming
7499c9f9a7 feat(lua): conversion between cursor positions 2025-08-24 19:38:38 +08:00
Yi Ming
a4a690e597 docs(lua): mark vim.Pos.Optional as optional 2025-08-24 19:38:38 +08:00
zeertzjq
523371b044 vim-patch:9.1.1681: tests: no test for actually moving cursor with 'acl' (#35452)
Problem:  tests: no test for actually moving cursor when menu is not
          open with 'autocompletedelay'.
Solution: Use <Up> first in the test. Also remove two unnecessary <Esc>s
          in completion timeout test (zeertzjq).

closes: vim/vim#18097

e8b99ff6d5
2025-08-24 11:33:44 +00:00
zeertzjq
0b8a9bde0e fix(diff): set default diff flags properly (#35450) 2025-08-24 14:42:10 +08:00
zeertzjq
810a234978 vim-patch:9.1.1672: completion: cannot add timeouts for 'cpt' sources (#35447)
Problem:  completion: cannot add timeouts for 'cpt' sources
          (Evgeni Chasnovski)
Solution: Add the 'autocompletetimeout' and 'completetimeout' options
          (Girish Palya)

fixes: vim/vim#17908
closes: vim/vim#17967

69a337edc1

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-08-24 13:16:55 +08:00
Jan Edmund Lazo
17601e709f vim-patch:9.1.0546: vim-tiny fails on CTRL-X/CTRL-A
Problem:  vim-tiny fails on CTRL-X/CTRL-A
          (Rob Foehl, after 9.1.0172)
Solution: Move #ifdefs, so that after changing the line in del_bytes,
          the cached textlen value is invalidated

closes: vim/vim#15178

03acd4761b

Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2025-08-23 23:47:26 -04:00
Yochem van Rosmalen
c1fa3c7c37 feat(gen_help_html): generate helptags.json, helptag.html #35442
Problem:
No way to know the html page with the docs of a tag when you only have
the tag name.

Solution:
Generate a helptags.json that maps tags to their locations.
Generate a helptag.html page that redirects to the HTML page of the given tag.

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2025-08-23 15:04:52 -07:00
Riley Bruins
29c5559ce1 fix(treesitter): show capture-level priorities in :Inspect #35443 2025-08-23 12:01:38 -07:00
github-actions[bot]
faff3617ba docs: update version.c #35411
vim-patch:8.2.0082: when reusing a buffer listeners are not cleared
vim-patch:8.2.0446: listener with undo of deleting all lines not tested
vim-patch:8.2.1092: not checking if saving for undo succeeds
vim-patch:8.2.3174: Vim9: "legacy undo" finds "undo" variable
vim-patch:8.2.3426: crash when deleting a listener in a listener callback
vim-patch:8.2.4142: build failure with normal features without persistent undo

vim-patch:9.0.0361: removing a listener may result in a memory leak
2025-08-23 11:59:34 -07:00
zeertzjq
ed40d89d7c Merge pull request #35427 from zeertzjq/vim-9.1.1638
vim-patch: 'autocompletedelay'
2025-08-23 21:24:17 +08:00
zeertzjq
963ead29d9 vim-patch:9.1.1670: completion: autocomplete breaks second completion
Problem:  completion: autocomplete breaks second completion
          (gravndal)
Solution: Fix the autocomplete bug (Girish Palya)

fixes: vim/vim#18044
closes: vim/vim#18068

b4e0bd93a9

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-08-23 20:40:59 +08:00
zeertzjq
1c0465bec6 vim-patch:5ca1ea8: runtime(doc): Tweak documentation style
closes: vim/vim#18078

5ca1ea83ad

Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
2025-08-23 20:40:59 +08:00
zeertzjq
6ef996a082 vim-patch:9.1.1657: Autocompletion adds delay
Problem:  Autocompletion adds delay
          (gcanat, char101, after v9.1.1638)
Solution: Temporarily disable autocomplation (Girish Palya).

related: vim/vim#17960
fixes: vim/vim#18022
closes: vim/vim#18048

196c376682

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-08-23 20:40:59 +08:00
zeertzjq
4019d3050d vim-patch:9.1.1638: completion: not possible to delay the autcompletion
Problem:  completion: not possible to delay the autcompletion
Solution: add the 'autocompletedelay' option value (Girish Palya).

This patch introduces a new global option 'autocompletedelay'/'acl' that
specifies the delay, in milliseconds, before the autocomplete menu
appears after typing.

When set to a non-zero value, Vim waits for the specified time before
showing the completion popup, allowing users to reduce distraction from
rapid suggestion pop-ups or to fine-tune the responsiveness of
completion.

The default value is 0, which preserves the current immediate-popup
behavior.

closes: vim/vim#17960

a09b1604d4

N/A patch: vim-patch:9.1.1641: a few compiler warnings are output

Co-authored-by: Girish Palya <girishji@gmail.com>
2025-08-23 20:40:58 +08:00
zeertzjq
639f9f4cda vim-patch:9.1.1667: Another outdated comment in eval.c (#35438)
Problem:  Another outdated comment in eval.c (after 9.1.1665).
Solution: Remove that comment as well. Add a few more tests for mapnew()
          that fail without patch 8.2.1672 (zeertzjq).

closes: vim/vim#18089

6b56711804
2025-08-23 10:35:18 +00:00
zeertzjq
b9699d5701 vim-patch:9.1.1665: Outdated comment in eval.c (#35436)
Problem:  Outdated comment in eval.c.
Solution: Remove the comment, which is no longer true after 8.2.1672.
          Also fix a typo in version9.txt (zeertzjq).

closes: vim/vim#18077

5d3c39af2a
2025-08-23 07:38:07 +08:00
glepnir
eeba0dc2ed fix: memory leak from double buffer initialization in read_stdin #35413
Problem: When stdin follows files, set_curbuf() initializes buffer via
enter_buffer(), then open_buffer() initializes again, causing memory leaks.

Solution: Use readfile() directly for new buffers already initialized by
enter_buffer(), only call open_buffer() for original buffer case.
2025-08-22 14:50:30 -07:00