Commit Graph

7486 Commits

Author SHA1 Message Date
zeertzjq
71faa2be88 fix(events): don't expand args.file for Lua callback (#31473)
Problem:  In an autocommand Lua callback whether `args.file` is expanded
          depends on whether `expand('<afile>')` has been called.
Solution: Always use the unexpanded file name for `args.file`.

Related to #31306 and vim/vim#16106. This doesn't provide `sfname`, but
at least makes `args.file` have a consistent value.
2024-12-10 10:19:01 +08:00
luukvbaal
6a63034b51 fix(completion): avoid deleting text when completion leader changes #31448
Problem:  When completion leader changes, text that might be reinserted
          immediately after is deleted. This unnecessarily affects
          extmarks. #31387 restored the original extmarks but that
          prevents end_right_gravity marks from growing.
Solution: Avoid deleting leader text that will be reinserted.
(cherry picked from commit e788d1a3a9)
2024-12-07 14:54:33 +00:00
zeertzjq
7ca0408a1f fix(defaults): don't replace keycodes in Visual search mappings (#31460)
Also remove "silent" to be more consistent with Normal mode search.
2024-12-05 19:33:33 +08:00
James McCoy
7781111fef
test(main_spec): make "nvim -v" test agnostic to build type
In release builds, the Compilation: line is omitted so the build is reproducible. Since the "fall-back for $VIM" line is always present, check for that instead.
2024-12-04 21:30:52 -05:00
James McCoy
4007c42b77
test(version_spec): expect vim.NIL, not nil, for "build" if not in a git clone 2024-12-04 21:30:52 -05:00
James McCoy
584b811aee
test(main_spec): use CMakePresets.json instead of .git for root marker 2024-12-04 21:30:51 -05:00
Gregory Anders
308e9719cf
fix(lsp): retrigger diagnostics request on server cancellation (#31345) (#31427)
Co-authored-by: Jesse <github@jessebakker.com>
(cherry picked from commit 29c72cdf4a)
2024-12-02 12:13:23 -06:00
luukvbaal
e80e8a0980 fix(extmark): builtin completion can still affect nearby extmarks #31387
Problem:
Built-in completion can still affect nearby extmarks. #31384

Solution:
Restore extmarks when completion leader changes.

(cherry picked from commit c7ec010ade)
2024-12-02 15:28:38 +00:00
Evgeni Chasnovski
163a532cfa fix(api): make nvim_set_hl() respect all cterm attributes (#31390)
(cherry picked from commit 8de1dc6923)
2024-12-02 00:51:14 +00:00
zeertzjq
1a12dea191 test(filetype): symlink detection works after expand('<afile>') (#31307)
Also add a test for #31306, which currently fails.

(cherry picked from commit c697c49a76)
2024-11-22 11:44:04 +00:00
zeertzjq
6f2786433d test(autocmd/termxx_spec): fix TextChangedT test flakiness (#31296)
Problem:  The E937 error appears for too short in TextChangedT test.
Solution: Only feed an Enter key after seeing the error.
(cherry picked from commit 3597633075)
2024-11-22 00:32:36 +00:00
Rafael Kitover
085f1cc99d
feat(main): expand file ~\ or ~/ prefix on Windows
In command_line_scan() for MSWIN, expand "~\" or "~/" prefixed paths to
the USERPROFILE environment variable for the user's profile directory.

Rename the static os_homedir() to os_uv_homedir() to emphasize that it
is a wrapper around a libuv function.

Add the function os_get_homedir() to os/env.c to return the cached
homedir value as a const. Must be called after homedir is initialized or
it fails.

The difference between this function and the static os_uv_homedir() is
that the latter gets the homedir from libuv and is used to initialize
homedir in init_homedir(), while os_get_homedir() just returns homedir
as a const if it's initialized and is public.

Use the os_get_homedir() accessor for ~/ expansion on Windows to make
the code more concise.

Add a Windows section to main_spec.lua with tests for expanding ~/ and
~\ prefixes for files passed in on the command-line.

Fix #23901

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2024-11-19 07:26:37 +08:00
Riley Bruins
3c0e1a89d9 fix(treesitter): show proper node name error messages
**Problem:** Currently node names with non-alphanumeric, non
underscore/hyphen characters (only possible with anonymous nodes) are
not given a proper error message. See tree-sitter issue 3892 for more
details.

**Solution:** Apply a different scanning logic to anonymous nodes to
correctly identify the entire node name (i.e., up until the final double
quote)

(cherry picked from commit 36990f324d)
2024-11-13 13:03:00 +00:00
zeertzjq
57b0fecd47 fix(startup): report --startuptime error to stderr (#31131)
Problem:  Crash when initializing for --startuptime errors.
Solution: Report the error to stderr, as neither logging nor messages
          have been initialized yet.
(cherry picked from commit 17e00d0cc6)
2024-11-13 05:47:28 +00:00
Luuk van Baal
98ec48eefb fix(inccommand): ensure cursor is where it belongs
Problem:  Inccommand preview callback may flush inaccurate cmdline cursor position.
Solution: Ensure cursor is where it belongs when doing command preview.
(cherry picked from commit 59e130b6ca)
2024-11-09 15:26:32 +00:00
zeertzjq
6a07b199ff vim-patch:9.1.0003: Cannot build against Ruby 33 dynamically (#30683)
Problem:  Cannot build against Ruby 33 dynamically
Solution: Ruby 33 removed transient heap, so do not use
          rb_ary_transient anymore, NoMethodError format changed,
          so update test for expected error message
          (Isao Sato)

- ruby-3.3 removed transient heap for ruby/dyn

when +ruby/dyn with ruby-3.3 do command :ruby, E448 occur.
ruby-3.3 has no transient heap anymore, so disable rb_ary_transient etc.

$ LC_ALL=C VIMRUNTIME=runtime ./src/vim -u NONE -c 'ruby puts RUBY_VERSION'
"=> Error detected while processing command line:
"=> E448: Could not load library function rb_ary_detransient
"=> E266: Sorry, this command is disabled, the Ruby library could not be
    loaded.

- ruby-3.3 changed NoMethodError format:

$ rvm 3.2.2, 3.3.0-rc1 do ruby -e 'begin; nil.name; rescue => e; puts "%s : %s"%[RUBY_VERSION, e.message]; end '
=> 3.2.2 : undefined method `name' for nil:NilClass
=> 3.3.0 : undefined method `name' for nil

so loose pattern in Test_ruby_Vim_buffer_get()

closes: vim/vim#13741

443657b32b

Co-authored-by: Isao Sato <svardew@gmail.com>
2024-11-09 13:11:47 +01:00
dundargoc
7774ca9107 ci: bump macos runner version to macos-15 2024-11-09 13:11:47 +01:00
Justin M. Keyes
348a939168 tests: skip watch.watchdirs test on macos 14 CI
Problem:
Strange failure only in macos 14 CI

    FAILED   test/functional/lua/watch_spec.lua @ 82: vim._watch watchdirs() detects file changes
    test/functional/lua/watch_spec.lua:149: Expected objects to be the same.
    Passed in:
    (table: 0x0116023758) {
     *[1] = {
        [change_type] = 3
       *[path] = '/Users/runner/work/neovim/neovim/build/Xtest_tmpdir/nvim_KFMvPbXk9a/nvim_KFMvPbXk9a' }
      [2] = {
        [change_type] = 3
        [path] = '/Users/runner/work/neovim/neovim/build/Xtest_tmpdir/nvim_KFMvPbXk9a/file' } }
    Expected:
    (table: 0x010d9d6548) {
     *[1] = {
        [change_type] = 1
       *[path] = '/Users/runner/work/neovim/neovim/build/Xtest_tmpdir/nvim_KFMvPbXk9a/file' }
      [2] = {
        [change_type] = 3
        [path] = '/Users/runner/work/neovim/neovim/build/Xtest_tmpdir/nvim_KFMvPbXk9a/file' } }

    stack traceback:
            test/functional/lua/watch_spec.lua:149: in function <test/functional/lua/watch_spec.lua:82>

Solution:
Skip test for that exact version.
2024-11-09 13:11:47 +01:00
neovim-backports[bot]
94f44122ad
test(012_directory_spec): fix flakiness on Windows (#30921)
test(012_directory_spec): fix flakiness on Windows (#30920)

Problem:  012_directory_spec is flaky on Windows.
Solution: Use :%bwipe! instead :qall!.
(cherry picked from commit fffcb88ad6)

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2024-10-24 11:57:40 +08:00
neovim-backports[bot]
0b0385ea6a
test(rpc): retry flaky 'vim.rpcrequest and vim.rpcnotify' test (#30922)
Problem: 'vim.rpcrequest and vim.rpcnotify' is flaky on Windows.

Solution: retry it.
(cherry picked from commit 6fd13eedda)

Co-authored-by: Christian Clason <c.clason@uni-graz.at>
2024-10-24 11:45:24 +08:00
zeertzjq
bbefbc995e fix(tui): avoid flushing buffer halfway an OSC 2 sequence (#30793)
Problem:  Setting title while TUI buffer is almost full may cause the
          end of a flush to be treated as a part of an OSC 2 or OSC 0
          sequence, leading to problems like invisible cursor.
Solution: Make the whole sequence to set title a unibi_ext string.
(cherry picked from commit 4846bf05dc)
2024-10-15 00:18:12 +00:00
zeertzjq
97aaea3478 test(tui_spec): use Unicode in cursor_address test (#30807)
Now that #16425 is fixed, use Unicode again to reduce screen height.
Unfortunately composing chars still can't be used, as it turns out that
composing chars may be missing when sent separately from the base char
at the last char a screen line.

(cherry picked from commit 1189c5ce59)
2024-10-14 08:20:44 +00:00
zeertzjq
1a02f1835f
test(autocmd/termxx_spec): properly setup TextChangedT tests (#30788) 2024-10-13 11:29:29 +08:00
zeertzjq
2d1a13bdf5 vim-patch:9.1.0776: test_strftime may fail because of missing TZ data (#30780)
Problem:  test_strftime may fail because of missing TZ data
Solution: Use GMT offsets to validate timezone differences (James McCoy)

Some systems only provide timezones that follow the geographical region
naming (e.g. America/New_York) by default and require an additional
install for other names (like EST).

The GMT+<offset> format must always be honored, so use that to generate
distinct data for the test.

closes: vim/vim#15848

ea997edc7a

Co-authored-by: James McCoy <jamessan@jamessan.com>
(cherry picked from commit b0ddc1783a)
2024-10-12 22:54:59 +00:00
zeertzjq
ee7885aa21 vim-patch:9.1.0759: screenpos() may return invalid position (#30681)
Problem:  screenpos() may return invalid position
          after switching buffers (Greg Hurrell)
Solution: reset w_leftcol if wrapping has been set
          after copying wrap option

fixes: vim/vim#15792
closes: vim/vim#15803

b065a10e24

Co-authored-by: Christian Brabandt <cb@256bit.org>
(cherry picked from commit 9f26bdc416)
2024-10-05 23:14:33 +00:00
zeertzjq
687c0078c2 vim-patch:9.1.0753: Wrong display when typing in diff mode with 'smoothscroll' (#30614)
Problem:  Wrong display when typing in diff mode with 'smoothscroll'.
Solution: Use adjust_plines_for_skipcol() (zeertzjq).

closes: vim/vim#15776

47f8584a80
(cherry picked from commit 0e484c2041)
2024-10-01 23:34:17 +00:00
Lewis Russell
f31e29fce4 fix(diff): use mmfile_t in linematch
Problem:

Linematch used to use strchr to navigate a string, however strchr does
not supoprt embedded NULs.

Solution:

Use `mmfile_t` instead of `char *` in linematch and introduce `strnchr()`.

Also remove heap allocations from `matching_char_iwhite()`

Fixes: #30505
(cherry picked from commit c65646c247)
2024-09-30 12:34:01 +01:00
zeertzjq
045afa9e8a fix(float): properly find last window of tabpage (#30571)
(cherry picked from commit df915f3afc)
2024-09-29 10:55:55 +00:00
zeertzjq
1fc09b0738 fix(column): set signcolumn width after splitting window (#30556)
(cherry picked from commit d5f6f61879)
2024-09-28 09:38:08 +00:00
zeertzjq
28fba3bf27 fix(window): making float with title/footer non-float leaks memory (#30551)
(cherry picked from commit 4f9311b759)
2024-09-28 02:44:46 +00:00
glepnir
2f3c447605 fix(window): respect hide flag of float windows when switching (#30507)
(cherry picked from commit 7b71fdbc1e)
2024-09-27 22:26:41 +00:00
zeertzjq
9b4e7c9a0d fix(api): fix crash/leak with float title/footer on error (#30543)
(cherry picked from commit f55213ce0e)
2024-09-27 15:01:24 +00:00
zeertzjq
6a0d1eee46 test(api/window_spec): remove duplicate test (#30538)
(cherry picked from commit eea6b84a87)
2024-09-27 11:47:55 +00:00
zeertzjq
d535482ab2 test(api/buffer_updates_spec): prevent flakiness (#30521)
Use poke_eventloop() to wait for Nvim to finish processing input.

(cherry picked from commit 66197dde70)
2024-09-26 10:57:12 +00:00
zeertzjq
e537379641
fix(channel): handle writing to file instead of pipe (#30520) 2024-09-26 08:43:51 +00:00
Justin M. Keyes
6a44055a71
backport: fix(vim.fs): dirname() returns "." on mingw/msys2 (#30484)
fix(vim.fs): dirname() returns "." on mingw/msys2 #30480

Problem:
`vim.fs.dirname([[C:\User\XXX\AppData\Local]])` returns "." on
mingw/msys2.

Solution:
- Check for "mingw" when deciding `iswin`.
- Use `has("win32")` where possible, it works in "fast" contexts since
  b02eeb6a72.
2024-09-23 13:41:47 +00:00
zeertzjq
2a8d80a442 test(tui_spec): prevent another case of race between paste and input (#30481)
Problem:  When input immediately follows end of bracketed paste, the
          nvim_input may be processed before the nvim_paste.
Solution: Ensure some waiting after the end of a bracketed paste.
(cherry picked from commit 5acdc4499e)
2024-09-23 12:14:20 +00:00
zeertzjq
a3f9bd7f79
feat(jumplist): allow opting out of removing unloaded buffers (#30419)
Problem:  Cannot opt out of removing unloaded buffers from the jumplist.
Solution: Only enable that with "clean" flag in 'jumpoptions'.
2024-09-19 10:32:50 +00:00
zeertzjq
4abd480e8f vim-patch:9.1.0730: Crash with cursor-screenline and narrow window
Problem:  Crash with cursor-screenline and narrow window
          (elig0n)
Solution: Don't set right_col when width2 is 0 (zeertzjq).

fixes: vim/vim#15677
closes: vim/vim#15678

59149f0269
(cherry picked from commit 5191a11d66)
2024-09-14 12:17:48 +00:00
zeertzjq
b4824edac1 vim-patch:9.1.0729: Wrong cursor-screenline when resizing window
Problem:  Wrong cursor-screenline when resizing window
Solution: Invalidate saved left_col and right_col when width1 or width2
          change.

closes: vim/vim#15679

86dc4f8b43
(cherry picked from commit 90585e47fe)
2024-09-14 12:17:48 +00:00
zeertzjq
260ac4b3a2 vim-patch:9.1.0728: [security]: heap-use-after-free in garbage collection with location list user data
Problem:  heap-use-after-free in garbage collection with location list
          user data.
Solution: Mark user data as in use when no other window is referencing
          the location list (zeertzjq)

fixes: neovim/neovim#30371
closes: vim/vim#15683

be4bd189d2
2024-09-14 19:35:17 +08:00
Justin M. Keyes
61b0816790
test(health): "test_plug/health/init.lua" completes as "test_plug"
(cherry picked from commit 7b680e0ca9)
2024-09-11 16:07:29 +01:00
Tristan Knight
b55435f438 fix(lsp): handle out-of-bounds character positions #30288
Problem:
str_byteindex_enc could return an error if the index was longer than the
lline length. This was handled in each of the calls to it individually

Solution:
* Fix the call at the source level so that if the index is higher than
  the line length, line length is returned as per LSP specification
* Remove pcalls on str_byteindex_enc calls. No longer needed now that
  str_byteindex_enc has a bounds check.
2024-09-08 21:01:58 +02:00
Luuk van Baal
95c3fd4dc0 fix(decor): exclude invalid marks from meta total
Problem:  Marktree meta count still includes invalidated marks, making
          guards that check the meta total ineffective.
Solution: Revise marktree metadata when in/revalidating a mark.
2024-09-06 14:20:46 +02:00
zeertzjq
886a8b62c5 vim-patch:9.1.0716: resetting setcellwidth() doesn't update the screen (#30274)
Problem:  resetting setcellwidth() doesn't update the screen
Solution: Redraw after clearing the cellwidth table (Ken Takata)

closes: vim/vim#15628

539e9b571a

Co-authored-by: Ken Takata <kentkt@csc.jp>
(cherry picked from commit d60c753cff)
2024-09-05 22:52:31 +00:00
vanaigr
26b72b0f91 fix(api): nvim_buf_get_text() crashes with large negative column #28740
Problem:
crash when calling nvim_buf_get_text() with a large negative start_col:

    call nvim_buf_get_text(0, 0, -123456789, 0, 0, {})

Solution:
clamp start_col after subtracting it from the line length.

(cherry picked from commit d1d7d54680)
2024-09-03 15:30:37 +02:00
zeertzjq
5cb3505ab8 fix(completion): don't include <Lua function> in -complete= (#30209)
(cherry picked from commit bfa365a872)
2024-08-31 23:58:51 +00:00
zeertzjq
1ed493cc96 vim-patch:9.1.0694: matchparen is slow on a long line (#30134)
Problem:  The matchparen plugin is slow on a long line.
Solution: Don't use a regexp to get char at and before cursor.
          (zeertzjq)

Example:

```vim
  call setline(1, repeat(' foobar', 100000))
  runtime plugin/matchparen.vim
  normal! $hhhhhhhh
```

closes: vim/vim#15568

81e7513c86
(cherry picked from commit cf44121f7f)
2024-08-24 22:08:04 +00:00
zeertzjq
40671f18f7 fix(decor): don't use separate DecorSignHighlight for url (#30096)
(cherry picked from commit a8fbe1d409)
2024-08-20 00:20:41 +00:00
neovim-backports[bot]
316fa168a1
fix(terminal): interrupt/got_int hangs terminal (#30094)
fix(terminal): interrupt/got_int hangs terminal (#30056)

Upon `terminal_enter`, `mapped_ctrl_c` is set in order to avoid `CTRL-C`
interrupts (which is proxied to the terminal process instead), `os_inchar`
will then test `mapped_ctrl_c` against `State` and set `ctrl_c_interrupts=false`
which prevents `process_ctrl_c` from setting `got_int=true` in a terminal
state.

However, if `got_int` is set outside of `process_ctrl_c`, e.g. via
`interrupt()`, this will hang the neovim process as `terminal_execute` will
enter an endless loop as `got_int` will never be cleared causing `safe_vgetc`
to always return `Ctrl_C`.

A minimal example reproducing this bug:
```vim
:autocmd TermEnter * call timer_start(500, {-> interrupt()})
:terminal
:startinsert
```

To fix, we make sure `got_int` is cleared inside `terminal_execute` when
it detects `Ctrl_C`.

Closes #20726

Co-authored-by: zeertzjq <zeertzjq@outlook.com>
Co-authored-by: ibhagwan <59988195+ibhagwan@users.noreply.github.com>
2024-08-20 06:48:13 +08:00