Commit Graph

6420 Commits

Author SHA1 Message Date
zeertzjq
054839437e
test(plugin/man_spec): use pesc() on actual_file in pattern (#25199) 2023-09-17 06:07:53 +08:00
bfredl
883e2a1409
Merge pull request #25186 from llllvvuu/fix/preserve_marktree_orderinh
fix(marktree): preserve ordering in `marktree_move`
2023-09-16 14:59:20 +02:00
bfredl
477458f7bf
fix(test): more tests for marktree
Co-Authored-By: L Lllvvuu <git@llllvvuu.dev>
2023-09-16 05:32:45 -07:00
L Lllvvuu
908843df61 fix(languagetree): apply resolve_lang to metadata['injection.language']
`resolve_lang` is applied to `@injection.language` when it's supplied as a
capture:

f5953edbac/runtime/lua/vim/treesitter/languagetree.lua (L766-L768)

If we want to support `metadata['injection.language']` (as per #22518 and
[tree-sitter upstream](https://tree-sitter.github.io/tree-sitter/syntax-highlighting#language-injection))
then the behavior should be consistent.

Fixes: nvim-treesitter/nvim-treesitter#4918
2023-09-16 11:12:06 +01:00
bfredl
40bfca744d
Merge pull request #25183 from llllvvuu/fix/marktree_move
fix(marktree): off-by-one error in `marktree_move`
2023-09-16 10:39:54 +02:00
bfredl
2d2cf150e1
Merge pull request #25078 from glepnir/au
fix(float): don't trigger au event when enter is false
2023-09-16 10:27:45 +02:00
L Lllvvuu
585549625d
fix(marktree): off-by-one error in marktree_move
If you would insert element X at position j, then if you are moving that
same element X from position i < j, you should move it to position j -
1, because you are losing an element.

This error caused a gap to be left in the array, so that it looked like
[x, null, y] instead of [x, y], where len = 2. This triggered #25147.

Fixes: #25147
2023-09-16 01:12:15 -07:00
zeertzjq
35e50d79c6
fix(extmarks): overlay virt_text position after 'showbreak' (#25175)
Also make virt_text_hide work properly.
2023-09-15 20:30:50 +08:00
glepnir
a916523574 fix(ui): doesn't trigger au event when enter is false 2023-09-15 19:18:01 +08:00
Ilia Choly
f5a09f1b03
fix: invoke changed_bytes when rewriting <Tab> char #25125
When tabstop and shiftwidth are not equal, tabs are inserted as individual
spaces and then rewritten as tab characters in a second pass. That second pass
did not call changed_bytes which resulted in events being omitted.

Fixes #25092
2023-09-15 03:45:51 -07:00
dundargoc
2d9e7a33f4
test(windows): unskip working tests (#25153)
Also simplify home detection with os_homedir()
2023-09-15 16:33:26 +08:00
zeertzjq
a6e4793baf
fix(extmarks): draw virt_text below diff filler lines properly (#25170)
fix(extmarks): draw virt_text properly below diff filler lines
2023-09-15 15:56:52 +08:00
zeertzjq
b65cd7ff1a
fix(extmarks): fix wrong virt_text position after wrapped TAB (#25168) 2023-09-15 14:54:42 +08:00
zeertzjq
b52bd8a2de
fix(extmarks): properly handle virt_text on next screen line (#25166)
TODO: virt_text_hide doesn't work for the first char on a wrapped screen
line, and it's not clear how to fix that.
2023-09-15 12:35:27 +08:00
zeertzjq
f5953edbac
fix(float): update position of anchored windows first (#25133) 2023-09-14 07:42:22 +08:00
bfredl
b04286a187 feat(extmark): support proper multiline ranges
The removes the previous restriction that nvim_buf_set_extmark()
could not be used to highlight arbitrary multi-line regions

The problem can be summarized as follows: let's assume an extmark with a
hl_group is placed covering the region (5,0) to (50,0) Now, consider
what happens if nvim needs to redraw a window covering the lines 20-30.
It needs to be able to ask the marktree what extmarks cover this region,
even if they don't begin or end here.

Therefore the marktree needs to be augmented with the information covers
a point, not just what marks begin or end there. To do this, we augment
each node with a field "intersect" which is a set the ids of the
marks which overlap this node, but only if it is not part of the set of
any parent. This ensures the number of nodes that need to be explicitly
marked grows only logarithmically with the total number of explicitly
nodes (and thus the number of of overlapping marks).

Thus we can quickly iterate all marks which overlaps any query position
by looking up what leaf node contains that position. Then we only need
to consider all "start" marks within that leaf node, and the "intersect"
set of that node and all its parents.

Now, and the major source of complexity is that the tree restructuring
operations (to ensure that each node has T-1 <= size <= 2*T-1) also need
to update these sets. If a full inner node is split in two, one of the
new parents might start to completely overlap some ranges and its ids
will need to be moved from its children's sets to its own set.
Similarly, if two undersized nodes gets joined into one, it might no
longer completely overlap some ranges, and now the children which do
needs to have the have the ids in its set instead. And then there are
the pivots! Yes the pivot operations when a child gets moved from one
parent to another.
2023-09-12 10:38:23 +02:00
Jaehwang Jung
65738202f8
fix(decorations): better approximation of botline #24794
Problem:
* The guessed botline might be smaller than the actual botline e.g. when
  there are folds and the user is typing in insert mode. This may result
  in incorrect treesitter highlights for injections.
* botline can be larger than the last line number of the buffer, which
  results in errors when placing extmarks.

Solution:
* Take a more conservative approximation. I am not sure if it is
  sufficient to guarantee correctness, but it seems to be good enough
  for the case mentioned above.
* Clamp it to the last line number.

Co-authored-by: Lewis Russell <me@lewisr.dev>
2023-09-11 12:29:39 -07:00
Sergey Slipchenko
f859d16aea
fix(tests): set SHELL=sh #24941
Problem:
Some tests fail with $SHELL=fish #6172
Related: https://github.com/neovim/neovim/pull/6176

Solution:
Replace "echo -n" with "printf", because "echo" in sh may be provided
as a shell builtin, which does not accept an "-n" flag to avoid a
trailing newline (e.g. on macos). "printf" is more portable (defined by
POSIX) and it does not output a trailing newline by itself.
Fixes #6172

TODO:
Other test failures may be related to "session leader" issue: https://github.com/neovim/neovim/issues/2354
Checked by running `:terminal ./build/bin/tty-test` from Nvim with
`shell=/bin/fish` (inherited from `$SHELL`) and it indeed complains
about "process does not own the terminal". With `shell=sh` it doesn't complain. And
unsetting `$SHELL` seems to make `nvim` to fall back to `shell=sh`.

    FAILED   test/functional/terminal/tui_spec.lua @ 1017: TUI paste: terminal mode
    test/functional/terminal/tui_spec.lua:1024: Row 1 did not match.
    Expected:
      |*tty ready                                         |
      |*{1: }                                                 |
      |*                                                  |
      |                                                  |
      |{5:^^^^^^^                                           }|
      |{3:-- TERMINAL --}                                    |
      |{3:-- TERMINAL --}                                    |
    Actual:
      |*process does not own the terminal                 |
      |*                                                  |
      |*[Process exited 2]{1: }                               |
      |                                                  |
      |{5:^^^^^^^                                           }|
      |{3:-- TERMINAL --}                                    |
      |{3:-- TERMINAL --}                                    |

    To print the expect() call that would assert the current screen state, use
    screen:snapshot_util(). In case of non-deterministic failures, use
    screen:redraw_debug() to show all intermediate screen states.

    stack traceback:
        test/functional/ui/screen.lua:622: in function '_wait'
        test/functional/ui/screen.lua:352: in function 'expect'
        test/functional/terminal/tui_spec.lua:1024: in function <test/functional/terminal/tui_spec.lua:1017>

    FAILED   test/functional/terminal/tui_spec.lua @ 1551: TUI forwards :term palette colors with termguicolors
    test/functional/terminal/tui_spec.lua:1567: Row 1 did not match.
    Expected:
      |*{1:t}ty ready                                         |
      |                                                  |
      |*                                                  |
      |                                                  |
      |{2:^^^^^^^                                           }|
      |                                                  |
      |{3:-- TERMINAL --}                                    |
    Actual:
      |*{1:p}rocess does not own the terminal                 |
      |                                                  |
      |*[Process exited 2]                                |
      |                                                  |
      |{2:^^^^^^^                                           }|
      |                                                  |
      |{3:-- TERMINAL --}                                    |

    To print the expect() call that would assert the current screen state, use
    screen:snapshot_util(). In case of non-deterministic failures, use
    screen:redraw_debug() to show all intermediate screen states.

    stack traceback:
        test/functional/ui/screen.lua:622: in function '_wait'
        test/functional/ui/screen.lua:352: in function 'expect'
        test/functional/terminal/tui_spec.lua:1567: in function <test/functional/terminal/tui_spec.lua:1551>
2023-09-11 10:01:00 -07:00
bfredl
616a9bac32
Merge pull request #24901 from faergeek/more-intuitive-cursor-update
fix(api): more intuitive cursor updates in nvim_buf_set_text
2023-09-11 10:45:45 +02:00
Christian Clason
60e5d0fbcc vim-patch:9.0.1891: No runtime support for Mojo
Problem:  No runtime support for Mojo
Solution: Add basic filetype and syntax plugins

closes: vim/vim#13062
closes: vim/vim#13063

0ce2c594d0

Co-authored-by: Mahmoud Abduljawad <mahmoud@masaar.com>
2023-09-11 10:05:54 +02:00
Sergey Slipchenko
d22172f36b
fix(api): more intuitive cursor updates in nvim_buf_set_text
Fixes #22526
2023-09-11 08:16:03 +04:00
zeertzjq
e8d25675a2 vim-patch:9.0.1894: CI: trailing whitespace in tests
Problem:  CI: trailing white space in tests
Solution: clean up the trailing white space

e5f7cd0a60

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-11 11:16:50 +08:00
zeertzjq
6484f338a4 vim-patch:9.0.1893: CI: strptime test fails on BSD14
Problem:  CI: strptime test fails on BSD14
Solution: Skip the test

983d808674

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-11 11:16:50 +08:00
zeertzjq
2b475cb5cc
fix(mouse): click on 'statuscolumn' with 'rightleft' (#25090) 2023-09-11 08:29:33 +08:00
Sergey Slipchenko
af0684f0d5
test: unignore test which froze sourcehut (#25067) 2023-09-11 05:53:05 +08:00
dundargoc
9f8f287c61 build: remove luarocks
Luarocks is no longer needed after
25e51d393a.
2023-09-10 15:32:47 +02:00
Grace Petryk
5e3cf9fb4b
feat(lsp): improve control over placement of floating windows (#24494) 2023-09-10 10:02:23 +02:00
bfredl
d4e80a051e
Merge pull request #25039 from glepnir/fix_hl
fix(highlight): add create param in nvim_get_hl api function
2023-09-09 13:01:40 +02:00
zeertzjq
b9d9cd7742 vim-patch:partial:9.0.1886: Various Typos
Problem:  Various Typos
Solution: Fix Typos

This is a collection of typo related commits.

closes: vim/vim#12753
closes: vim/vim#13016

ee17b6f70d

Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Adri Verhoef <a3@a3.xs4all.nl>
Co-authored-by: Viktor Szépe <viktor@szepe.net>
Co-authored-by: nuid64 <lvkuzvesov@proton.me>
Co-authored-by: Meng Xiangzhuo <aumo@foxmail.com>
Co-authored-by: Dominique Pellé <dominique.pelle@gmail.com>
2023-09-09 17:58:32 +08:00
zeertzjq
bc09fc04b8 vim-patch:9.0.1877: missing test for patch 9.0.1873
Problem:  missing test for patch 9.0.1873
Solution: add a test trying to exchange windows

Add a test, making sure that switching windows is not allowed when
textlock is active, e.g. when running `:s/<pat>/\=func()/`

18d2709aa1

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-09 17:53:01 +08:00
glepnir
8afb3a49c0 fix(highlight): add create param in nvim_get_hl 2023-09-09 17:15:58 +08:00
bfredl
5970157e1d refactor(map): enhanced implementation, Clean Code™, etc etc
This involves two redesigns of the map.c implementations:

1. Change of macro style and code organization

The old khash.h and map.c implementation used huge #define blocks with a
lot of backslash line continuations.

This instead uses the "implementation file" .c.h pattern. Such a file is
meant to be included multiple times, with different macros set prior to
inclusion as parameters. we already use this pattern e.g. for
eval/typval_encode.c.h to implement different typval encoders reusing a
similar structure.

We can structure this code into two parts. one that only depends on key
type and is enough to implement sets, and one which depends on both key
and value to implement maps (as a wrapper around sets, with an added
value[] array)

2. Separate the main hash buckets from the key / value arrays

Change the hack buckets to only contain an index into separate key /
value arrays
This is a common pattern in modern, state of the art hashmap
implementations. Even though this leads to one more allocated array, it
is this often is a net reduction of memory consumption. Consider
key+value consuming at least 12 bytes per pair. On average, we will have
twice as many buckets per item.
Thus old implementation:

  2*12 = 24 bytes per item

New implementation

  1*12 + 2*4 = 20 bytes per item

And the difference gets bigger with larger items.
One might think we have pulled a fast one here, as wouldn't the average size of
the new key/value arrays be 1.5 slots per items due to amortized grows?
But remember, these arrays are fully dense, and thus the accessed memory,
measured in _cache lines_, the unit which actually matters, will be the
fully used memory but just rounded up to the nearest cache line
boundary.

This has some other interesting properties, such as an insert-only
set/map will be fully ordered by insert only. Preserving this ordering
in face of deletions is more tricky tho. As we currently don't use
ordered maps, the "delete" operation maintains compactness of the item
arrays in the simplest way by breaking the ordering. It would be
possible to implement an order-preserving delete although at some cost,
like allowing the items array to become non-dense until the next rehash.

Finally, in face of these two major changes, all code used in khash.h
has been integrated into map.c and friends. Given the heavy edits it
makes no sense to "layer" the code into a vendored and a wrapper part.
Rather, the layered cake follows the specialization depth: code shared
for all maps, code specialized to a key type (and its equivalence
relation), and finally code specialized to value+key type.
2023-09-08 12:48:46 +02:00
bfredl
6985e12cae refactor(build): derocksify luacheck 2023-09-07 15:26:30 +02:00
Tom Praschan
131a1ee82d
feat(lsp): add original LSP Location as item's user_data in locations_to_items (#23743) 2023-09-07 10:12:02 +02:00
Evgeni Chasnovski
d272143318
fix(diagnostic): always return copies of diagnostic items (#25010) 2023-09-06 12:54:18 -05:00
zeertzjq
0909843647 vim-patch:9.0.1874: CI may fail in test_recover_empty_swap
Problem:  CI may fail in test_recover_empty_swap
Solution: Set directory option

Fix failing Test_recover_empty_swap test

:recover by default not only looks in the current directory, but also in
~/tmp for files to recover. If it finds some files to recover, it will
interactively prompt for a file to recover. However, prompting doesn't
work when running the test suite (and even if it would, there is no one
that can answer the prompt).

So it doesn't really make sense during testing, to inspect different
directories for swap files and prompt and wait (which will lead to a
timeout and therefore a failing test).

So set the 'directory' option temporarily to the current directory only
and reset it back once the test finishes.

closes: vim/vim#13038

1c7397f3f1

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-06 06:28:23 +08:00
zeertzjq
3e5a7f258a vim-patch:partial:9.0.0669: too many delete() calls in tests
Problem:    Too many delete() calls in tests.
Solution:   Use deferred delete where possible.

db77cb3c08

Include test_recover.vim changes only.
Cherry-pick test_recover.vim change from patch 8.2.3637.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-09-06 06:28:23 +08:00
zeertzjq
33d6cf70cc
test(old): reorder test_quickfix.vim to match upstream (#25029) 2023-09-06 06:28:03 +08:00
Lewis Russell
4ce9875feb
Merge pull request #25006 from lewis6991/fix/systemkill
`vim.system` fixes and improvements
2023-09-05 21:50:18 +01:00
Lewis Russell
80d1333b73 refactor(vim.system): factor out on_exit handling 2023-09-05 17:10:04 +01:00
Lewis Russell
6d5f12efd2 fix(vim.system): make timeout work properly
Mimic the behaviour of timeout(1) from coreutils.
2023-09-05 17:10:01 +01:00
zeertzjq
c3e176f6e2
fix(options): correct condition for calling did_set_option() (#25026) 2023-09-05 20:03:25 +08:00
Lewis Russell
a44521f46e fix(vim.system): let on_exit handle cleanup after kill
Fixes #25000
2023-09-05 10:18:26 +01:00
zeertzjq
65d3378009
vim-patch:9.0.1866: undo is synced after character find (#25021)
vim-patch:9.0.1866: undo is synced after character find

Problem:  Undo is synced after character find.
Solution: Set no_u_sync when calling gotchars_nop().

closes: vim/vim#13022
closes: vim/vim#13024

dccc29c228
2023-09-05 06:25:51 +08:00
zeertzjq
c431d820e7
vim-patch:9.0.1856: issues with formatting positional arguments (#25013)
Problem:  issues with formatting positional arguments
Solution: fix them, add tests and documentation

closes: vim/vim#12140
closes: vim/vim#12985

Tentatively fix message_test. Check NULL ptr.

aa90d4f031

Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
2023-09-04 08:49:50 +08:00
zeertzjq
bebdf1dab3
vim-patch:9.0.1848: [security] buffer-overflow in vim_regsub_both() (#25001)
Problem:  buffer-overflow in vim_regsub_both()
Solution: Check remaining space

ced2c7394a

The change to do_sub() looks confusing. Maybe it's an overflow check?
Then the crash may not be applicable to Nvim because of different casts.
The test also looks confusing. It seems to source itself recursively.
Also don't call strlen() twice on evaluation result.

N/A patches for version.c:
vim-patch:9.0.1849: CI error on different signedness in ex_cmds.c
vim-patch:9.0.1853: CI error on different signedness in regexp.c

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-03 13:47:55 +08:00
zeertzjq
087ef52997
vim-patch:9.0.1840: [security] use-after-free in do_ecmd (#24993)
Problem:  use-after-free in do_ecmd
Solution: Verify oldwin pointer after reset_VIsual()

e1dc9a6275

N/A patches for version.c:
vim-patch:9.0.1841: style: trailing whitespace in ex_cmds.c

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-03 11:15:43 +08:00
Maria José Solano
517dfdf0fc
fix(shada): update marks when using delmarks! (#24978) 2023-09-03 10:34:09 +08:00
zeertzjq
b55010a539 vim-patch:9.0.1846: [security] crash in fullcommand
Problem:  crash in fullcommand
Solution: Check for typeval correctly

4c6fe2e2ea

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-03 09:14:30 +08:00
zeertzjq
272c4fba83
vim-patch:9.0.1852: i_CTRL-O does not reset Select Mode (#24990)
Problem:  i_CTRL-O does not reset Select Mode
Solution: Reset select mode on CTRL-O in insert mode

closes: vim/vim#13001
closes: vim/vim#12115

d69aecf141

Co-authored-by: pierreganty <pierreganty@gmail.com>
Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-09-03 09:04:58 +08:00
dundargoc
f30844008b
build: download busted from own neovim/deps repository
Downloading the necessary files all at once instead of doing dependency
handling with luarocks speeds up installation immensely. We speed up the
process even more by using luv as a replacement for the C modules in the
busted dependencies, which allows us to skip costly compilation times.

Co-authored-by: bfredl <bjorn.linse@gmail.com>
2023-09-03 00:38:10 +02:00
zeertzjq
0c86828ac5
fix(ui): avoid ambiguity about chunk that clears part of line (#24982)
Co-authored-by: bfredl <bjorn.linse@gmail.com>
2023-09-02 18:50:12 +08:00
zeertzjq
bc43575c52
test(shada/marks_spec): load the file with the marks (#24979) 2023-09-02 10:23:43 +08:00
zeertzjq
592a8f1e90
vim-patch:9.0.1828: cursor wrong with virt text before double-width char (#24967)
Problem:  Wrong cursor position with virtual text before double-width
          char at window edge.
Solution: Check for double-width char before adding virtual text size.

closes: vim/vim#12977

ac2d8815ae
2023-09-01 06:45:27 +08:00
Lewis Russell
dd0e77d48a fix(query_error): multiline bug 2023-08-31 15:12:17 +01:00
Amaan Qureshi
845d5b8b64 feat(treesitter): improve query error message 2023-08-31 13:33:40 +01:00
Chris AtLee
c235959fd9
fix(lsp): only disable inlay hints / diagnostics if no other clients are connected (#24535)
This fixes the issue where the LspNotify handlers for inlay_hint /
diagnostics would end up refreshing all attached clients.

The handler would call util._refresh, which called
vim.lsp.buf_request, which calls the method on all attached clients.

Now util._refresh takes an optional client_id parameter, which is used
to specify a specific client to update.

This commit also fixes util._refresh's handling of the `only_visible`
flag. Previously if `only_visible` was false, two requests would be made
to the server: one for the visible region, and one for the entire file.

Co-authored-by: Stanislav Asunkin <1353637+stasjok@users.noreply.github.com>
Co-authored-by: Mathias Fußenegger <mfussenegger@users.noreply.github.com>
2023-08-31 10:00:24 +02:00
Maria José Solano
ee56daebb6
fix(shada): update deleted marks (#24936)
Fix #4295
Close #16067

Co-authored-by: chentau <tchen1998@gmail.com>
2023-08-31 10:15:49 +08:00
zeertzjq
839d919098
vim-patch:9.0.1825: wrong cursor position with virt text and 'linebreak' (#24957)
Problem:  Wrong cursor position with virtual text before a whitespace
          character and 'linebreak'.
Solution: Always set "col_adj" to "size - 1" and apply 'linebreak' after
          adding the size of 'breakindent' and 'showbreak'.

closes: vim/vim#12956

6e55e85f92

N/A patches:
vim-patch:9.0.1826: keytrans() doesn't translate recorded key typed in a GUI
2023-08-31 08:35:08 +08:00
zeertzjq
5d49542b56
vim-patch:9.0.1820: Rexx files may not be recognised (#24956)
Problem:  Rexx files may not be recognised
Solution: Add shebang detection and improve disambiguation of *.cls
	  files

closes: vim/vim#12951

e06afb7860

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2023-08-31 08:20:00 +08:00
zeertzjq
7914881356
vim-patch:9.0.1797: Vimball/Visual Basic filetype detection conflict (#24947)
Problem:  Vimball/Visual Basic filetype detection conflict
Solution: runtime(vb): Improve Vimball and Visual Basic detection logic

Only run Vimball Archiver's BufEnter autocommand on Vimball archives.
Fixes vim/vim#2694.

closes: vim/vim#12899

f97f6bbf56

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2023-08-31 07:44:33 +08:00
zeertzjq
6463116818
vim-patch:9.0.1807: runtime: crystal scripts not recognised (#24949)
Problem:  runtime: crystal scripts not recognised
Solution: Filetype detect Crystal scripts by shebang line

closes: vim/vim#12935

9b73902dbe

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2023-08-31 04:38:28 +08:00
zeertzjq
497cf996eb
vim-patch:9.0.1803: runtime(filetype): Add norg language detection (#24948)
runtime(filetype): Add norg markup language detection

closes: vim/vim#12913

03e44a1d70

Co-authored-by: NTBBloodbath <bloodbathalchemist@protonmail.com>
2023-08-31 04:38:01 +08:00
bfredl
b051b131f5 fix(api): nvim_buf_get_offset in a new buffer with zero or one lines
fixes #24930
2023-08-30 12:01:35 +02:00
bfredl
50a03c0e99 fix(treesitter): fix another TSNode:tree() double free
Unfortunately the gc=false objects can refer to a dangling tree if the
gc=true tree was freed first. This reuses the same tree object as the
node itself is keeping alive via the uservalue of the node userdata.
(wrapped in a table due to lua 5.1 restrictions)
2023-08-29 11:35:46 +02:00
nwounkn
6e45567b49
fix(treesitter): fix TSNode:tree() double free (#24796)
Problem: `push_tree`, every time its called for the same TSTree with
`do_copy=false` argument, creates a new userdata for it. Each userdata,
when garbage collected, frees the same TSTree C object.

Solution: Add flag to userdata, which indicates, should C object,
which userdata points to, be freed, when userdata is garbage collected.
2023-08-29 10:48:23 +02:00
bfredl
0a81ec14a4 fix(api): better topline adjustments in nvim_buf_set_lines
Some more reasonable defaults for topline:
  - if topline was replaced with another line, that now becomes topline
  - if line was inserted just before topline, display it. This is more
    similar to the previous API behavior.
2023-08-29 09:26:15 +02:00
zeertzjq
794981d9be
vim-patch:9.0.1813: linebreak incorrect drawn with breakindent (#24917)
Problem: 'linebreak' is incorrectly drawn after 'breakindent'.
Solution: Don't include 'breakindent' size when already after it.

closes: vim/vim#12937
closes: vim/vim#12940

1d3e0e8f31
2023-08-29 09:36:55 +08:00
bfredl
132bbd1cbd fix(api): handle clearing out last line of non-current buffer
fixes #24911
2023-08-28 12:39:02 +02:00
zeertzjq
656be8a591
vim-patch:9.0.1810: camel-case spelling has issues with digits (#24909)
Problem:  camel-case spelling has issues with digits
Solution: Improve the camCase spell checking by taking digits
          and caps into account

Rewrite the conditions to check for word boundaries by taking into
account the presence of digits and all-caps sequences such as acronyms.

closes: vim/vim#12644
closes: vim/vim#12933

d08745040b

Co-authored-by: LemonBoy <thatlemon@gmail.com>
2023-08-28 07:16:15 +08:00
zeertzjq
6b12eda220
vim-patch:9.0.1798: The 'syntax' option has no completion. (#24908)
Problem:  The 'syntax' option has no completion.
Solution: Add syntax option completion.

closes: vim/vim#12900

6dfdff3f27

N/A patches:
vim-patch:9.0.1795: Indentation issues

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2023-08-28 07:07:50 +08:00
zeertzjq
062db5c136 vim-patch:9.0.1802: Multiline regex with Visual selection fails with virtual text
Problem:  Multiline regex with Visual selection fails when Visual
          selection contains virtual text after last char.
Solution: Only include virtual text after last char when getting full
          line length.

closes: vim/vim#12908

e3daa06be1
2023-08-28 06:10:36 +08:00
zeertzjq
c70aa84b2a vim-patch:9.0.1800: Cursor position still wrong with 'showbreak' and virtual text
Problem:  Cursor position still wrong with 'showbreak' and virtual text
          after last character or 'listchars' "eol".
Solution: Remove unnecessary w_wcol adjustment in curs_columns(). Also
          fix first char of virtual text not shown at the start of a screen
          line.

closes: vim/vim#12478
closes: vim/vim#12532
closes: vim/vim#12904

6a3897232a
2023-08-28 06:02:01 +08:00
zeertzjq
128091a256 fix(ui): wrong cursor position with left gravity inline virt text at eol 2023-08-28 05:51:01 +08:00
Lewis Russell
abb8c2c453 fix(editorconfig): do not set 'endofline'
Problem:
  'endofline' can be used to detect if a file ends of <EOL>, however
  editorconfig can break this.

Solution:
  Set 'endofline' during BufWritePre

Fixes: #24869
2023-08-27 19:27:25 +01:00
zeertzjq
1f49c98036
vim-patch:9.0.1792: problem with gj/gk/gM and virtual text (#24898)
Problem:  Normal mode "gM", "gj", "gk" commands behave incorrectly with
          virtual text.
Solution: Use linetabsize() instead of linetabsize_str().

closes: vim/vim#12909

d809c0a903
2023-08-27 20:04:44 +08:00
bfredl
840749d6c9 fix(undo): fix crash caused by checking undolevels in wrong buffer
fixes #24894
2023-08-27 12:08:11 +02:00
bfredl
9b9030ff2c fix(api): fix inconsistent behavior of topline touched in recent refactor
The change in #24824 0081549 was not a regression, however it was an
incomplete change. Unfortunately some common plugins come to depend on
this exising self-inconsistent behavior. These plugins are going to need
to update for 0.10

nvim_buf_set_lines used to NOT adjust the topline correctly if a buffer
was displayed in just one window. However, if displayed in multiple
windows, it was correctly adjusted for any window not deemed the
current window for the buffer (which could be an arbitrary choice if the
buffer was not already current, as noted in the last rafactor)

This fixes so that all windows have their topline adjusted. The added
tests show this behavior, which should be the reasonable one.
2023-08-27 12:07:46 +02:00
Evgeni Chasnovski
35570e4a11
feat(float): implement footer
Problem: Now way to show text at the bottom part of floating window
  border (a.k.a. "footer").

Solution: Allows `footer` and `footer_pos` config fields similar to
  `title` and `title_pos`.
2023-08-26 19:37:43 +03:00
luukvbaal
afd0c648a8
fix(statuscolumn): force full redraw when signcolumn is invalid (#24859)
Fix #24655
2023-08-26 21:10:04 +08:00
Ibby
362df0f793
fix(extmarks): wrong display when changing text with virt_lines (#24879) 2023-08-26 19:39:05 +08:00
bfredl
0081549547 refactor(change): do API changes to buffer without curbuf switch
Most of the messy things when changing a non-current buffer is
not about the buffer, it is about windows. In particular, it is about
`curwin`.

When editing a non-current buffer which is displayed in some other
window in the current tabpage, one such window will be "borrowed" as the
curwin. But this means if two or more non-current windows displayed the buffers,
one of them will be treated differenty. this is not desirable.

In particular, with nvim_buf_set_text, cursor _column_ position was only
corrected for one single window. Two new tests are added: the test
with just one non-current window passes, but the one with two didn't.

Two corresponding such tests were also added for nvim_buf_set_lines.
This already worked correctly on master, but make sure this is
well-tested for future refactors.

Also, nvim_create_buf no longer invokes autocmds just because you happened
to use `scratch=true`. No option value was changed, therefore OptionSet
must not be fired.
2023-08-26 12:02:05 +02:00
zeertzjq
a9418ef8cf
fix(ui): wrong display with 0-width inline virt_text at eol (#24854) 2023-08-24 11:28:10 +08:00
Amaan Qureshi
c6ec7fa8d7 feat(treesitter): add 'injection.self' and 'injection.parent'
Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
2023-08-24 09:05:44 +09:00
zeertzjq
466c18b818
vim-patch:9.0.1785: wrong cursor position with 'showbreak' and lcs-eol (#24852)
Problem:  wrong cursor position with 'showbreak' and lcs-eol
Solution: Add size of 'showbreak' before when 'listchars' "eol" is used.
          Also fix wrong cursor position with wrapping virtual text on
          empty line and 'showbreak'.

closes: vim/vim#12891

1193951beb
2023-08-24 07:19:18 +08:00
zeertzjq
08fa71fd27
vim-patch:9.0.1773: cannot distinguish Forth and Fortran *.f files (#24841)
Problem:  cannot distinguish Forth and Fortran *.f files
Solution: Add Filetype detection Code

Also add *.4th as a Forth filetype

closes: vim/vim#12251

19a3bc3add

Don't remove filetype files from Vim patches:
- filetype.vim, script.vim, ft.vim usually contain useful changes
- script.vim and ft.vim don't even have their paths spelled correctly

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2023-08-23 19:32:11 +08:00
zeertzjq
3f32cb88c2 vim-patch:9.0.1781: Problems when setting bin/paste option
Problem:  Problems when setting bin/paste option
Solution: When setting binary/paste, remember that this also affects
          depending options, so that :verbose set returns the right
          location.

Mention if depending options for 'binary' or 'paste' have been reset
indirectly. Add a test to verify it works.

Also noticed as small bug, that the global option value for expandtab
was not reset when paste option is set, so fix that while at it.

closes: vim/vim#12837
closes: vim/vim#12879

757593c07a

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-08-23 18:24:14 +08:00
zeertzjq
0ba27bb51d vim-patch:9.0.1710: scrolloff options work slightly different
Problem: sidescrolloff and scrolloff options work slightly
         different than other global-local options
Solution: Make it behave consistent for all global-local options

It was noticed, that sidescrolloff and scrolloff options behave
differently in comparison to other global-local window options like
'listchars'

So make those two behave like other global-local options. Also add some
extra documentation for a few special local-window options.

Add a few tests to make sure all global-local window options behave
similar

closes: vim/vim#12956
closes: vim/vim#12643

4a8eb6e7a9

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-08-23 18:24:14 +08:00
zeertzjq
908f247c22 fix(plines): count 'showbreak' for virtual text at eol 2023-08-23 13:17:17 +08:00
zeertzjq
a1d71ad55e vim-patch:9.0.1783: Display issues with virt text smoothscroll and showbreak
Problem:  Wrong display with wrapping virtual text or unprintable chars,
          'showbreak' and 'smoothscroll'.
Solution: Don't skip cells taken by 'showbreak' in screen lines before
          "w_skipcol". Combined "n_skip" and "skip_cells".

closes: vim/vim#12597

b557f48982
2023-08-23 13:17:17 +08:00
zeertzjq
6462ee1c10
vim-patch:9.0.1779: Need more state() tests (#24840)
Problem:  Need more state() tests
Solution: Add a few more tests for operater pending mode and register
          yank command

closes: vim/vim#12883

8dabccd295
2023-08-23 06:42:10 +08:00
zeertzjq
20f76ebf2b
test: fix state() test flakiness (#24839) 2023-08-23 00:00:57 +08:00
zeertzjq
b84a67f50e
vim-patch:9.0.0579: using freed memory when 'tagfunc' wipes out buffer (#24838)
Problem:    Using freed memory when 'tagfunc' wipes out buffer that holds
            'complete'.
Solution:   Make a copy of the option.  Make sure cursor position is valid.

0ff01835a4

Cherry-pick a cmdwin change from patch 9.0.0500.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-22 22:48:55 +08:00
zeertzjq
e34eb4ccf9
test(old): reorder test_edit.vim to match upstream (#24837) 2023-08-22 20:57:10 +08:00
zeertzjq
63094e0013
vim-patch:8.0.0571: negative line number when using :z^ in an empty buffer (#24836)
Problem:    The cursor line number becomes negative when using :z^ in an empty
            buffer. (neovim vim/vim#6557)
Solution:   Correct the line number.  Also reset the column.

a364cdb648

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-22 20:56:14 +08:00
zeertzjq
3f1a12b8cc
test(old): remove workaround for TSAN CI (#24834)
Now that TSAN CI no longer runs oldtests, match upstream better.
2023-08-22 20:03:03 +08:00
zeertzjq
94f2da09e1
vim-patch:8.2.4611: typos in tests; one lua line not covered by test (#24835)
Problem:    Typos in tests; one lua line not covered by test.
Solution:   Fix typos. Add test case. (Dominique Pellé, closes vim/vim#9994)

81b573d7e5

Cherry-pick test_menu.vim change from patch 9.0.1453.

N/A patch:
vim-patch:8.2.3045: minor typos

Co-authored-by: Dominique Pelle <dominique.pelle@gmail.com>
2023-08-22 20:02:50 +08:00
zeertzjq
09910d5b35 vim-patch:9.0.0837: append() reports failure when not appending anything
Problem:    append() reports failure when not appending anything.
Solution:   Only report failure when appending something. (closes vim/vim#11498)

cd9c8d400c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-22 18:56:43 +08:00
zeertzjq
48722ec400 vim-patch:9.0.0428: autocmd test uses common file name
Problem:    Autocmd test uses common file name.
Solution:   Use unique name to reduce flakiness.

be9fc5b60c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-22 18:56:43 +08:00
zeertzjq
1da705c433 vim-patch:9.0.0425: autocmd test is a bit flaky on MS-Windows
Problem:    Autocmd test is a bit flaky on MS-Windows.
Solution:   Add a bit more sleeping. (Ken Takata, closes vim/vim#11095)

ae04a6049b

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-22 18:56:43 +08:00
zeertzjq
10990eace2 vim-patch:9.0.0415: on MS-Windows some tests are flaky
Problem:    On MS-Windows some tests are flaky.
Solution:   Add sleeps, disable swapfile, mark test as flaky. (Ken Takata,
            closes vim/vim#11082)

0500e87eba

Co-authored-by: K.Takata <kentkt@csc.jp>
2023-08-22 18:56:43 +08:00
zeertzjq
c170708023 vim-patch:9.0.0391: using separate delete() call instead of writefile() 'D' flag
Problem:    Using separate delete() call instead of writefile() 'D' flag.
Solution:   Use the writefile 'D' flag.

3411265a36

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-22 18:56:43 +08:00
zeertzjq
50b069a8b9 vim-patch:9.0.0380: deleting files in tests is a hassle
Problem:    Deleting files in tests is a hassle.
Solution:   Use the new 'D' flag of writefile().

e1f3ab73bc

vim-patch:e1f3ab73bc7c

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-22 18:56:43 +08:00
zeertzjq
d401b33314
fix(terminal): handle horizontal scrolling in another window (#24828) 2023-08-21 23:19:12 +08:00
Gregory Anders
d0717a7c4e
vim-patch:9.0.0423: "for" and "while" not recognized after :vim9cmd and :legacy (#24825)
Problem:    "for" and "while" not recognized after :vim9cmd and :legacy.
            (Emanuele Torre)
Solution:   Recognize all the command modifiers. (closes vim/vim#11087)
            Add a test to check the list of modifiers.

9132426334

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 09:06:21 -05:00
zeertzjq
28c2e83fb4 vim-patch:9.0.0313: using common name in tests leads to flaky tests
Problem:    Using common name in tests leads to flaky tests.
Solution:   Rename files and directories to be more specific.

e7cda97b6b

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 16:31:31 +08:00
zeertzjq
00ad0c81b6 vim-patch:9.0.0077: wrong restored cursor position when switching window in autocmd
Problem:    When switching window in autocmd the restored cursor position may
            be wrong.
Solution:   Do not restore the cursor if it was not set. (closes vim/vim#10775)

b03950fafa

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 16:25:48 +08:00
zeertzjq
bd9a9e63bc vim-patch:8.2.4212: window title test still fails in some configurations
Problem:    Window title test still fails in some configurations.
Solution:   Explicitly set the 'title' option.

1450112eef

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 16:17:01 +08:00
zeertzjq
67edc0a772 vim-patch:8.2.4211: window title test still fails in some configurations
Problem:    Window title test still fails in some configurations.
Solution:   Use WaitForAssert().

3a8ad5918b

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 16:16:53 +08:00
zeertzjq
7fab06cb0c vim-patch:8.2.4210: window title test fails in some configurations
Problem:    Window title test fails in some configurations.
Solution:   Only run the test if the title can be obtained.

a6c09a7c20

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 16:16:43 +08:00
zeertzjq
893437512c vim-patch:8.2.4208: using setbufvar() may change the window title
Problem:    Using setbufvar() may change the window title.
Solution:   Do not redraw when creating the autocommand window. (closes vim/vim#9613)

dff97e65eb

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 16:16:22 +08:00
zeertzjq
02ca31979b vim-patch:8.2.4339: CTRL-A does not work properly with the cmdline popup menu
Problem:    CTRL-A does not work properly with the cmdline popup menu.
Solution:   Fix issues with CTRL-A.  Add more tests for the cmdline popup
            menu.  Remove TermWait() before VeriryScreenDump().  Refactor the
            cmdline popup code. (Yegappan Lakshmanan, closes vim/vim#9735)

560dff49c0

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-21 15:43:39 +08:00
zeertzjq
00f92f086e vim-patch:8.2.3518: Test_xrestore sometimes fails
Problem:    Test_xrestore sometimes fails.
Solution:   Mark the test as flayky.  Move marking test as flaky to the test
            instead of listing them in runtest.

f08b0eb869

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 15:35:08 +08:00
zeertzjq
7aa3f825cd vim-patch:8.2.2910: test for cmdline window and terminal fails on MS-Windows
Problem:    Test for cmdline window and terminal fails on MS-Windows.
Solution:   Skip the test on MS-Windows.

0b49648486

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 15:31:21 +08:00
zeertzjq
d4b6a25e67 vim-patch:8.2.2908: crash when using a terminal popup window from cmdline window
Problem:    Crash when using a terminal popup window from the cmdline window.
Solution:   Instead of checking cmdwin_type call cmdwin_is_active().
            (closes vim/vim#8286)

e5b4486c42

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 15:31:21 +08:00
zeertzjq
ff801ce7f7 vim-patch:8.2.0533: tests using term_wait() can still be flaky
Problem:    Tests using term_wait() can still be flaky.
Solution:   Increase the wait time when rerunning a test. (James McCoy,
            closes vim/vim#5899)  Halve the initial times to make tests run faster
            when there is no rerun.

6a2c5a7dd5

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 15:31:21 +08:00
zeertzjq
ff37916b47 vim-patch:8.2.0454: some tests fail when the system is slow
Problem:    Some tests fail when the system is slow.
Solution:   Make the run number global, use in the test to increase the
            waiting time. (closes vim/vim#5841)

3ed9efc2b1

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 15:31:21 +08:00
zeertzjq
045cc185d5 vim-patch:8.2.0310: autocmd test fails on a slow system
Problem:    Autocmd test fails on a slow system.
Solution:   Adjust the expectations. (James McCoy, closes vim/vim#5685)

8fb1b47a5e

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 15:31:21 +08:00
zeertzjq
702a5f0cbb vim-patch:8.2.0195: some tests fail when run in the GUI
Problem:    Some tests fail when run in the GUI.
Solution:   Make sure the window width is enough.  In the GUI run terminal Vim
            in the terminal, if possible.

3180fe6c6d

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 15:31:21 +08:00
zeertzjq
e8df2a012b vim-patch:8.2.0186: a couple of tests may fail when features are missing
Problem:    A couple of tests may fail when features are missing.
Solution:   Check for features. (Dominique Pelle, closes vim/vim#5561)

705724e430

Just copy the two 'wincolor' test functions from Vim.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 15:31:21 +08:00
zeertzjq
6f5ff5818a vim-patch:8.1.2403: autocmd test fails under valgrind
Problem:    Autocmd test fails under valgrind.
Solution:   Wait a bit longer.

3c47e8384d

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 15:31:21 +08:00
zeertzjq
6aa29d0f01 test: add some tests for SafeState autocommand 2023-08-21 14:16:16 +08:00
zeertzjq
71acb71043 vim-patch:8.1.2099: state() test fails on some Mac systems
Problem:    state() test fails on some Mac systems.
Solution:   Increase the wait time. (closes vim/vim#4983)

b7a97ef340

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 14:16:16 +08:00
zeertzjq
e05031097c vim-patch:8.1.2069: test for SafeStateAgain may still fail
Problem:    Test for SafeStateAgain may still fail.
Solution:   Send another message to trigger SafeStateAgain.

0f6629a08a

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 14:16:16 +08:00
zeertzjq
0defbd38e4 vim-patch:8.1.2068: test for SafeState and SafeStateAgain may fail
Problem:    Test for SafeState and SafeStateAgain may fail.
Solution:   Accept more possible responses

513537bfff

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 14:16:16 +08:00
zeertzjq
3e79afec54 vim-patch:8.1.2067: no tests for SafeState and SafeStateAgain
Problem:    No tests for SafeState and SafeStateAgain.
Solution:   Add tests.

cadbe1b1fb

This test is quite useless. Don't port to Lua.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 14:16:16 +08:00
zeertzjq
6bf5b2428b vim-patch:8.1.2066: no tests for state()
Problem:    No tests for state().
Solution:   Add tests.  Clean up some feature checks.  Make "a" flag work.

c258549032

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-21 14:16:16 +08:00
Christian Clason
eaad2f7806 vim-patch:9.0.1768: Runtime: no support for bicep files
Problem:  Runtime: no support for bicep files
Solution: Add filetype support for bicepparam

closes: vim/vim#12784

2d0988ef93

Co-authored-by: Scott McKendry <scott.c.mckendry@gmail.com>
2023-08-21 10:13:44 +09:00
Christian Clason
a5b6468e9b vim-patch:9.0.1766: Runtime: Missing QML support
Problem:  Runtime: Missing QML support
Solution: Add QML support to Vim

closes: vim/vim#12810

bedc69f9d6

Co-authored-by: ChaseKnowlden <haroldknowlden@gmail.com>
2023-08-21 10:13:44 +09:00
zeertzjq
a2a226170d
vim-patch:9.0.1772: Cursor may be adjusted in 'splitkeep'ed windows (#24811)
Problem:    Cursor is adjusted in window that did not change in size by
            'splitkeep'.
Solution:   Only check that cursor position is valid in a window that
            has changed in size.

closes: vim/vim#12509

16af913eee

Co-authored-by: Luuk van Baal <luukvbaal@gmail.com>
2023-08-21 08:58:18 +08:00
zeertzjq
694814cdd5
vim-patch:9.0.1774: no support for custom cmdline completion (#24808)
Problem:  no support for custom cmdline completion
Solution: Add new vimscript functions

Add the following two functions:
- getcmdcompltype() returns custom and customlist functions

- getcompletion() supports both custom and customlist

closes: vim/vim#12228

92997dda78

Co-authored-by: Shougo Matsushita <Shougo.Matsu@gmail.com>
2023-08-21 07:29:49 +08:00
zeertzjq
ac99e63d73
vim-patch:9.0.1763: crash when passing invalid buffer to undotree() (#24807)
Problem:  crash when passing invalid buffer to undotree()
Solution: Use get_buf_arg() instead of tv_get_buf_from_arg().

closes: vim/vim#12862
closes: vim/vim#12830

ab9f2ecfd4
2023-08-21 07:20:26 +08:00
zeertzjq
d21e6285e9
vim-patch:9.0.1759: Visual highlight not working with cursor at end of screen line (#24806)
Problem:  Visual highlight not working with cursor at end of screen line
          and 'showbreak'.
Solution: Only update "vcol_prev" when drawing buffer text.

closes: vim/vim#12865

8fc6a1dae0
2023-08-21 07:18:39 +08:00
zeertzjq
0c91cb4f03 vim-patch:9.0.1761: g<kEnd> behaves different from g<end>
Problem:  g<kEnd> behaves different from g<end>
Solution: Make g<kEnd> behave like g<End>

closes: vim/vim#12861

654bdbbd32
2023-08-21 06:12:03 +08:00
zeertzjq
7485fd0518 vim-patch:9.0.1753: can't move to last non-blank char
Problem: can't move to last non-blank char
Solution: Make g<end> behave like that

Make it possible to move to last non-blank char on a line

We can distinguish between g0 and g^ to move to the very first character
and the first non-blank char.

And while we can move to the last screen char, we cannot go to the last
non-blank screen char.

Since I think g$ is the more widely used and known movement command (and
g<end> is synonymous to it) change the behaviour of g<end> to move to
last non-screen char instead and don't have this be the same command as
the g$ command anymore.

If you want to keep the old behaviour, you can use:

```
nnoremap g<end> g$
```

Add a test to verify the behaviour.

closes: vim/vim#12593

b5f6fe9ca2

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-08-21 06:11:16 +08:00
zeertzjq
421713523e
vim-patch:9.0.1745: Missing test coverage for blockwise Visual highlight (#24790)
Problem:  Missing test coverage for blockwise Visual highlight with
          virtual that starts with a double-width char.
Solution: Add a new virtual text to the test. Some other small fixes.

closes: vim/vim#12835

fc3058495d
2023-08-19 20:34:58 +08:00
zeertzjq
c8e58bf09c
vim-patch:9.0.1742: wrong curswant when clicking on second cell of double-width char (#24789)
Problem:  Wrong curswant when clicking and the second cell of a
          double-width char.
Solution: Don't copy virtcol of the first char to the second one.

closes: vim/vim#12842

9994160bfe
2023-08-19 19:40:26 +08:00
zeertzjq
fcd729f22c vim-patch:9.0.1540: reverse() on string doesn't work in compiled function
Problem:    reverse() on string doesn't work in compiled function.
Solution:   Accept string in argument type check. (Yegappan Lakshmanan,
            closes vim/vim#12377)

f9dc278946

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-19 18:05:46 +08:00
zeertzjq
4c7df98e4e vim-patch:9.0.1515: reverse() does not work for a String
Problem:    reverse() does not work for a String.
Solution:   Implement reverse() for a String. (Yegappan Lakshmanan,
            closes vim/vim#12179)

03ff1c2dde

vim-patch:9.0.1738: Duplicate code to reverse a string

Problem:  Duplicate code to reverse a string
Solution: Move reverse_text() to strings.c and remove string_reverse().

closes: vim/vim#12847

4dd266cb66

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-19 18:05:46 +08:00
zeertzjq
5a6c7c805b
fix(extmarks): make empty "conceal" respect &conceallevel = 1 (#24785)
This treats extmark conceal more like matchadd() conceal.
2023-08-19 03:55:11 +08:00
zeertzjq
1d3d50e8f0 test(ui/mouse_spec): mouse click with matchadd() concealed text 2023-08-18 19:34:25 +08:00
zeertzjq
551998b7ee vim-patch:9.0.1725: cursor pos wrong after concealed text with 'virtualedit'
Problem:    Wrong cursor position when clicking after concealed text
            with 'virtualedit'.
Solution:   Store virtual columns in ScreenCols[] instead of text
            columns, and always use coladvance() when clicking.

This also fixes incorrect curswant when clicking on a TAB, so now
Test_normal_click_on_ctrl_char() asserts the same results as the ones
before patch 9.0.0048.

closes: vim/vim#12808

e500ae8e29

Remove the mouse_adjust_click() function.

There is a difference in behavior with the old mouse_adjust_click()
approach: when clicking on the character immediately after concealed
text that is completely hidden, cursor is put on the clicked character
rather than at the start of the concealed text. The new behavior is
better, but it causes unnecessary scrolling in a functional test (which
is an existing issue unrelated to these patches), so adjust the test.

Now fully merged:
vim-patch:9.0.0177: cursor position wrong with 'virtualedit' and mouse click
2023-08-18 19:34:16 +08:00
zeertzjq
b0dda500e9 vim-patch:9.0.1705: cursor position wrong when clicking on an unprintable char
Problem:  cursor position wrong when clicking on an unprintable char
Solution: Don't update prev_ptr when wlv.n_extra is not zero.

closes: vim/vim#12664

b25dbb3f9b

Tests only. Code superseded by patch 9.0.1725.
2023-08-18 19:34:16 +08:00
zeertzjq
5ff725fa94 vim-patch:9.0.0048: cursor in wrong column with mouse click after concealed text
Problem:    Cursor in wrong column with mouse click after concealed text.
Solution:   Store the text column when drawing text.

b90818867c

Tests only. Code changes moved to the port of patch 9.0.1725.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-18 19:34:07 +08:00
zeertzjq
81d5550d77
vim-patch:9.0.1731: blockwise Visual highlight not working with virtual text (#24779)
Problem: blockwise Visual highlight not working with virtual text
Solution: Reset the correct variable at the end of virtual selection and
          Check for double-width char inside virtual text.

closes: vim/vim#12606

6e940d9a1d

Need to remove area_active and use wlv.fromcol and wlv.tocol directly.
2023-08-18 14:00:12 +08:00
zeertzjq
71ad771ea4
fix(ui_compositor): only reset skipstart at first column (#24776)
Problem:    A double-width char in a floating window causes an extra
            space to be drawn to the left of its boundary.
Solution:   Only reset skipstart at the first column.

Fix #24775
2023-08-18 12:08:18 +08:00
zeertzjq
c54682f75a
vim-patch:9.0.1729: screenpos() wrong when w_skipcol and cpoptions+=n (#24773)
Problem:    screenpos() wrong result with w_skipcol and cpoptions+=n
Solution:   Use adjust_plines_for_skipcol() instead of subtracting
            w_skipcol.

closes: vim/vim#12625

bfe377b8f2
2023-08-18 09:01:50 +08:00
zeertzjq
f8afa8023e
vim-patch:9.0.1728: missing winid argument for virtcol() (#24770)
Problem: missing winid argument for virtcol()
Solution: Add a {winid} argument to virtcol()

Other functions col(), charcol() and virtcol2col() support a {winid}
argument, so it makes sense for virtcol() to also support than.

Also add test for virtcol2col() with 'showbreak' and {winid}.

closes: vim/vim#12633

825cf813fa
2023-08-18 08:42:45 +08:00
zeertzjq
46163ddf5d
vim-patch:9.0.1730: passing multiple patterns to runtime not working (#24771)
Problem: passing multiple patterns to runtime not working
Solution: prepend prefix to each argument separately

closes: vim/vim#12617

008c91537b
2023-08-18 08:24:49 +08:00
zeertzjq
19d7fb8efe
vim-patch:9.0.1734: :runtime completion fails for multiple args (#24767)
Problem: :runtime completion fails for multiple args
Solution: Make it work

closes: vim/vim#12616

be5cdd1d63
2023-08-18 06:20:06 +08:00
Sean Dewar
9f7e7455c0
vim-patch:9.0.1726: incorrect heights in win_size_restore() (#24765)
Problem: incorrect heights in win_size_restore()
Solution: avoid restoring incorrect heights in win_size_restore()

876f5fb570

I already merged this prior, so just replace the new test with the old one,
but add a test case for the global statusline.
2023-08-17 23:16:19 +01:00
zeertzjq
bb29ef4008 vim-patch:9.0.1723: Fix regression in {func} argument of reduce()
Problem: Fix regression in {func} argument of reduce()
Solution: pass function name as string again

Before patch 9.0.0548, passing a string as {func} argument of reduce()
is treated as a function name, but after patch 9.0.0548 it is treated as
an expression instead, which is useless as reduce() doesn't set any v:
variables. This PR restores the behavior of {func} before that patch.

Also correct an emsg() call, as e_string_list_or_blob_required doesn't
contain format specifiers.

closes: vim/vim#12824

ad0c442f1f
2023-08-18 05:29:05 +08:00
zeertzjq
ffb87f4dd9 vim-patch:9.0.1722: wrong error messages when passing wrong types to count()
Problem: wrong error messages when passing wrong types to count()
Solution: fix it

This fixes two problems:
1. When passing wrong type to {ic} argument of count(), two error
   messages are given, the second of which is misleading.
2. When passing wrong type to {comp} argument of count(), the error
   message doesn't mention that {comp} may be a String.

closes: vim/vim#12825

4f389e7c0f
2023-08-18 05:28:42 +08:00
zeertzjq
8ac9abd4fa vim-patch:9.0.1416: crash when collection is modified when using filter()
Problem:    Crash when collection is modified when using filter().
Solution:   Lock the list/dict/blob. (Ernie Rael, closes vim/vim#12183)

e6d40dcdc7

Co-authored-by: Ernie Rael <errael@raelity.com>
2023-08-17 17:03:10 +08:00
zeertzjq
1ed12a2e10 vim-patch:9.0.0548: reduce() with a compiled lambda could be faster
Problem:    reduce() with a compiled lambda could be faster.
Solution:   Call eval_expr_typval() instead of call_func() directly.

f1c60d4bf1

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-17 16:44:55 +08:00
zeertzjq
1918e1ea6d vim-patch:9.0.0359: error message for wrong argument type is not specific
Problem:    Error message for wrong argument type is not specific.
Solution:   Include more information in the error. (Yegappan Lakshmanan,
            closes vim/vim#11037)

8deb2b30c7

Cherry-pick test_listdict.vim changes from patch 8.2.4809.

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-17 16:40:51 +08:00
zeertzjq
6267996f13 vim-patch:8.2.4455: accepting one and zero for second sort() argument is strange
Problem:    Accepting one and zero for the second sort() argument is strange.
Solution:   Disallow using one and zero in Vim9 script.

2007dd49f5

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-17 16:11:17 +08:00
zeertzjq
0b1353c5a4 vim-patch:8.2.4451: sort() fails when ignoring case
Problem:    sort() fails when ignoring case.
Solution:   Accept a number one argument in sort().

9cd4c0fb98

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-17 16:06:51 +08:00
zeertzjq
cda0abdb02 vim-patch:8.2.4450: list sort test fails
Problem:    List sort test fails.
Solution:   Pass a valid "how" argument.

2afeb40831

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-17 16:06:51 +08:00
zeertzjq
b193674b4a vim-patch:partial:8.2.3849: functions implementing reduce and map are too long
Problem:    Functions implementing reduce and map are too long.
Solution:   Use a function for each type of value.  Add a few more test cases
            and add to the help. (Yegappan Lakshmanan, closes vim/vim#9370)

389b72196e

Partial port as this doesn't include handling for non-materialized List.

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-17 15:37:32 +08:00
zeertzjq
c5576fcc80 vim-patch:8.2.3848: cannot use reduce() for a string
Problem:    Cannot use reduce() for a string.
Solution:   Make reduce() work with a string. (Naruhiko Nishino, closes vim/vim#9366)

0ccb5842f5

Omit tv_get_first_char() as it doesn't really save much code.

Co-authored-by: rbtnn <naru123456789@gmail.com>
2023-08-17 15:20:47 +08:00
zeertzjq
acac1e19d3 vim-patch:8.2.3982: some lines of code not covered by tests
Problem:    Some lines of code not covered by tests.
Solution:   Add a few more test cases. (Dominique Pellé, closes vim/vim#9453)

8bfa0eb863

Co-authored-by: Dominique Pelle <dominique.pelle@gmail.com>
2023-08-17 13:14:32 +08:00
zeertzjq
db64280be5 vim-patch:8.2.3908: cannot use a script-local function for 'foldtext'
Problem:    Cannot use a script-local function for 'foldtext'.
Solution:   Expand "s:" and "<SID>". (Yegappan Lakshmanan, closes vim/vim#9411)

27708e6c7b

Cherry-pick test_filter_map.vim change from patch 8.2.3871.

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-17 13:14:32 +08:00
zeertzjq
faef577e90 vim-patch:8.2.3822: leaking memory in map() and filter(), no string in Vim9
Problem:    Leaking memory in map() and filter(), cannot use a string argument
            in Vim9 script.
Solution:   Fix the leak, adjust the argument check, also run the tests as
            Vim9 script. (Yegappan Lakshmanan, closes vim/vim#9354)

2d877599ee

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-17 13:14:32 +08:00
zeertzjq
d9e7dad139 vim-patch:8.2.3818: cannot filter or map characters in a string
Problem:    Cannot filter or map characters in a string.
Solution:   Make filter() and map() work on a string. (Naruhiko Nishino,
            closes vim/vim#9327)

c479ce032f

Co-authored-by: rbtnn <naru123456789@gmail.com>
2023-08-17 13:14:32 +08:00
zeertzjq
3117dc70f1 vim-patch:1b884a005398
Update runtime files.

1b884a0053

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-17 11:21:10 +08:00
zeertzjq
90ad3c8f17 vim-patch:8.2.2075: error for const argument to mapnew()
Problem:    Error for const argument to mapnew().
Solution:   Don't give an error. (closes vim/vim#7400)

57cf4973a2

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-17 11:21:10 +08:00
zeertzjq
8cbb2477cf vim-patch:8.2.1969: Vim9: map() may change the list or dict item type
Problem:    Vim9: map() may change the list or dict item type.
Solution:   Add mapnew().

ea696852e7

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-17 11:21:10 +08:00
Sean Dewar
22d9338afc
fix(api): disallow win_set_buf from changing cmdwin's old curbuf (#24745)
A command typed in the cmdwin and executed with `<CR>` is expected to be
executed in the context of the old curwin/buf, so it shouldn't be changed.
2023-08-17 00:53:10 +01:00
zeertzjq
e928161bde vim-patch:8.2.3334: Vim9: not enough tests run with Vim9
Problem:    Vim9: not enough tests run with Vim9.
Solution:   Run a few more tests in Vim9 script and :def function. Fix
            islocked().  Fix error for locking local variable.

bd77aa9274

Omit GLV_NO_DECL: Vim9 script only.

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-16 21:50:56 +08:00
zeertzjq
56befb6fb3 vim-patch:8.2.3333: Vim9: not enough tests run with Vim9
Problem:    Vim9: not enough tests run with Vim9.
Solution:   Run a few more tests in Vim9 script and :def function.

3e9c0b9608

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-16 21:50:56 +08:00
Michael Strobel
e780177506
feat(diagnostic): filter diagnostics by specific severities (#24736)
Allow users to filter diagnostics by specifying severities
2023-08-16 08:49:14 -05:00
zeertzjq
f92bda1dad
vim-patch:9.0.1718: dict-completion does not respect region (#24733)
Problem: dict-completion does not respect region
Solution: respect selected region in dict completion

Set do_region to zero as we don't want a complete dump of the matching
words, we want the code to filter them according to the user's selected
region.

closes: vim/vim#12792
closes: vim/vim#7025

e98fb643ec

Co-authored-by: LemonBoy <thatlemon@gmail.com>
2023-08-16 07:12:47 +08:00
zeertzjq
a245dd79a2
vim-patch:9.0.1717: virtcol2col returns last byte of a multi-byte char (#24729)
Problem: virtcol2col returns last byte of a multi-byte char
Solution: Make it return the first byte for a multi-byte char

closes: vim/vim#12786
closes: vim/vim#12799

b209b86e66

Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2023-08-16 06:28:52 +08:00
zeertzjq
10c5f35a8d
vim-patch:9.0.1715: duplicate test in message_test.c (#24728)
Problem: duplicate test in message_test.c
Solution: Remove duplicate test and make functions static

closes: vim/vim#12803

7772c93a3e
2023-08-16 06:11:05 +08:00
zeertzjq
3cd5ef63fd
vim-patch:9.0.1714: getcompletion() "cmdline" fails after :autocmd (#24727)
Problem:  getcompletion() "cmdline" fails after :autocmd
Solution: Use set_cmd_context() instead of set_one_cmd_context().

closes: vim/vim#12804

e4c79d3615
2023-08-16 06:07:01 +08:00
Gregory Anders
e72c0cd920
feat(highlight): Allow hyphens (-) in highlight group names (#24714)
Fixes: https://github.com/neovim/neovim/issues/23184
2023-08-15 09:25:51 -05:00
zeertzjq
fc14928719
fix(printf): make positional %zd and %zu work (#24722) 2023-08-15 20:54:28 +08:00
zeertzjq
842a47d6a4
vim-patch:9.0.1704: Cannot use positional arguments for printf() (#24719)
Problem: Cannot use positional arguments for printf()
Solution: Support positional arguments in string formatting

closes: vim/vim#12140

0c6181fec4

Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
2023-08-15 19:16:19 +08:00
zeertzjq
389165cac1
vim-patch:8.2.0066: some corners of vim_snprintf() are not tested (#24718)
Problem:    Some corners of vim_snprintf() are not tested.
Solution:   Add a test in C. (Dominique Pelle, closes vim/vim#5422)

d2c946bacf
2023-08-15 14:46:05 +08:00
zeertzjq
fbc644ba31
vim-patch:9.0.1708: getcompletion() failes for user-defined commands (#24707)
Problem: getcompletion() failes for user-defined commands
Solution: set context for completion function

closes: vim/vim#12681
closes: vim/vim#12680

8ef1fbc0c3

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-08-14 06:47:32 +08:00
zeertzjq
06bce8bf5c
test(terminal): fix scrollback test flakiness (#24708)
Problem:    Terminal scrollback test is flaky.
Solution:   Use INTERACT flag so the job doesn't exit immediately.
2023-08-14 06:47:09 +08:00
Christian Clason
fc0ee871de fix(treesitter)!: remove deprecated legacy injection format 2023-08-14 00:14:35 +02:00
Christian Clason
11590543eb
Merge pull request #24681 from clason/update-c
feat(treesitter): update C parser and queries
2023-08-13 18:19:01 +02:00
zeertzjq
017ff93b02
fix(keycodes): recognize <t_xx> as a key (#24700)
Problem:    The result of keytrans() sometimes can't be translated back.
Solution:   Recognize <t_xx> as a key.
2023-08-13 22:14:48 +08:00
Justin M. Keyes
0fe921663f
Merge #15440 close 'shell' :terminal automatically 2023-08-13 05:23:15 -07:00
Christian Clason
3836eeb901 feat(treesitter): update C queries from upstream 2023-08-13 12:30:47 +02:00
Lewis Russell
8179d68dc1 fix(treesitter): logger memory leak 2023-08-13 11:23:17 +01:00
Lewis Russell
d8e330bcec fix(test): remove test/compat.lua 2023-08-13 10:20:05 +01:00
shafouz
7b0123dd6a
feat(remote): avoid --remote-ui infinite loop (#24465) 2023-08-13 14:14:08 +08:00
zeertzjq
d39361f5e0
vim-patch:9.0.1698: Test_map_restore_sid fails in GUI (#24682)
Problem: Test_map_restore_sid fails in GUI
Solution: Feed an unsimplified Ctrl-B

closes: vim/vim#12770

7fe1089904
2023-08-13 07:10:43 +08:00
zeertzjq
7542286d6a
vim-patch:9.0.1697: incsearch test not sufficient (#24683)
Problem: incsearch test not sufficient (after 9.0.1691)
Solution: add an additional test

73b8209266

Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
2023-08-13 07:10:24 +08:00
Lewis Russell
2ca076e45f feat(treesitter)!: incremental injection parsing
Problem:

Treesitter highlighting is slow for large files with lots of injections.

Solution:

Only parse injections we are going to render during a redraw cycle.

---

- `LanguageTree:parse()` will no longer parse injections by default and
  now requires an explicit range argument to be passed.

- `TSHighlighter` now parses injections incrementally during on_win
  callbacks for the line range being rendered.

- Plugins which require certain injections to be parsed must run
  `parser:parse({ start_row, end_row })` before using the tree.
2023-08-12 16:11:36 +01:00
Jaehwang Jung
5a25dcc5a4
fix(diff): filler lines for hunks bigger than linematch limit (#24676)
Apply linematch filler computation only if the hunk is actually
linematched.

Fixes #24580
2023-08-12 17:14:37 +08:00
zeertzjq
58a1ef8e6a
fix(events): avoid unnecessary CursorMoved (#24675)
Problem:    Temporarily changing current window in a script causes
            CursorMoved to be triggerd.
Solution:   Don't trigger CursorMoved if neither curwin nor cursor
            changed between two checks.
2023-08-12 09:50:17 +08:00
zeertzjq
6c07a189f2
vim-patch:9.0.1688: cannot store custom data in quickfix list (#24673)
Problem: cannot store custom data in quickfix list
Solution: add `user_data` field for the quickfix list

closes: vim/vim#11818

ca6ac99077

Co-authored-by: Tom Praschan <13141438+tom-anders@users.noreply.github.com>
2023-08-12 08:19:06 +08:00
zeertzjq
72cf94fc0e
vim-patch:9.0.1694: wrong mapping applied when replaying a char search (#24670)
Problem: wrong mapping applied when replaying a char search
Solution: Store a NOP after the ESC

closes: vim/vim#12708
closes: vim/vim#6350

bacc83009b
2023-08-12 06:50:52 +08:00
zeertzjq
8c5d81997e
vim-patch:9.0.1693: Ctrl-Q not handled like Ctrl-V in replace mode (#24669)
Problem: Ctrl-Q not handled like Ctrl-V in replace mode
Solution: Handle Ctrl-Q like Ctrl-V

closes: vim/vim#12686
closes: vim/vim#12684

2d63e4b3cc

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-08-12 06:41:23 +08:00
zeertzjq
8f9c5ee5ef
vim-patch:9.0.1691: wrong viewport restored for incsearch and smoothscroll (#24667)
Problem: wrong viewport restored for incsearch and smoothscroll
Solution: Save and restore skipcol as well

closes: vim/vim#12713

7b7b4cb6f2
2023-08-12 06:32:13 +08:00
zeertzjq
713311be62
vim-patch:9.0.1687: mapset() not properly handling script ID (#24666)
Problem: mapset() not properly handling script ID
Solution: replace_termcodes() may accept a script ID

closes: vim/vim#12699
closes: vim/vim#12697

7e0bae024d
2023-08-12 06:08:07 +08:00
zeertzjq
6e0c36ba0e
vim-patch:9.0.1686: undotree() only works for the current buffer (#24665)
Problem:    undotree() only works for the current buffer
Solution:   Add an optional "buffer number" parameter to undotree().  If
            omitted, use the current buffer for backwards compatibility.

closes: vim/vim#4001
closes: vim/vim#12292

5fee111149

Co-authored-by: Devin J. Pohly <djpohly@gmail.com>
2023-08-12 05:51:49 +08:00
Christian Clason
31c4ed26bc
feat(treesitter): add injection language fallback (#24659)
* feat(treesitter): add injection language fallback

Problem: injection languages are often specified via aliases (e.g.,
filetype or in upper case), requiring custom directives.

Solution: include lookup logic (try as parser name, then filetype, then
lowercase) in LanguageTree itself and remove `#inject-language`
directive.

Co-authored-by: Lewis Russell <me@lewisr.dev>
2023-08-11 17:05:17 +02:00
Gregory Anders
673ee213e9 test: update tests for auto-closing :term buffers
The terminal buffer closes automatically when using `:terminal` and the
command exits without an error. This messes up some tests that expect
the terminal buffer to still be open. We can force the buffer not to
close by passing an argument to `:terminal`. This can be anything, since
the shell-test stub simply prints whatever argument it's given.
2023-08-10 09:08:25 -05:00
zeertzjq
3d948a4dc4
vim-patch:9.0.1683: Updated runtime files (#24638)
This is a collection of various PRs from github that all require a minor
patch number:

1) https://github.com/vim/vim/pull/12612

    Do not conflate dictionary key with end of block

2) https://github.com/vim/vim/pull/12729:

    When saving and restoring 'undolevels', the constructs `&undolevels` and
    `:set undolevels` are problematic.

    The construct `&undolevels` reads an unpredictable value; it will be the
    local option value (if one has been set), or the global option value
    (otherwise), making it unsuitable for saving a value for later
    restoration.

    Similarly, if a local option value has been set for 'undolevels',
    temporarily modifying the option via `:set undolevels` changes the local
    value as well as the global value, requiring extra work to restore both
    values.

    Saving and restoring the option value in one step via the construct
    `:let &undolevels = &undolevels` appears to make no changes to the
    'undolevels' option, but if a local option has been set to a different
    value than the global option, it has the unintended effect of changing
    the global 'undolevels' value to the local value.

    Update the documentation to explain these issues and recommend explicit
    use of global and local option values when saving and restoring.  Update
    some unit tests to use `g:undolevels`.

3) https://github.com/vim/vim/pull/12702:

    Problem:    Pip requirements files are not recognized.
    Solution:   Add a pattern to match pip requirements files.

4) https://github.com/vim/vim/pull/12688:

    Add indent file and tests for ABB Rapid

5) https://github.com/vim/vim/pull/12668:

    Use Lua 5.1 numeric escapes in tests and add to CI

    Only Lua 5.2+ and LuaJIT understand hexadecimal escapes in strings.  Lua
    5.1 only supports decimal escapes:

    > A character in a string can also be specified by its numerical value
    > using the escape sequence \ddd, where ddd is a sequence of up to three
    > decimal digits. (Note that if a numerical escape is to be followed by a
    > digit, it must be expressed using exactly three digits.) Strings in Lua
    > can contain any 8-bit value, including embedded zeros, which can be
    > specified as '\0'.

    To make sure this works with Lua 5.4 and Lua 5.1 change the Vim CI to
    run with Lua 5.1 as well as Lua 5.4

6) https://github.com/vim/vim/pull/12631:

    Add hurl filetype detection

7) https://github.com/vim/vim/pull/12573:

    Problem:   Files for haskell persistent library are not recognized
    Solution:  Add pattern persistentmodels for haskell persistent library

closes: vim/vim#12612
closes: vim/vim#12729
closes: vim/vim#12702
closes: vim/vim#12688
closes: vim/vim#12668
closes: vim/vim#12631
closes: vim/vim#12573

Already ported but wasn't marked: vim-patch:ad34abee2583

6efb198033

Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: lacygoill <lacygoill@lacygoill.me>
Co-authored-by: Michael Henry <drmikehenry@drmikehenry.com>
Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
Co-authored-by: KnoP-01 <knosowski@graeffrobotics.de>
Co-authored-by: James McCoy <jamessan@jamessan.com>
Co-authored-by: Jacob Pfeifer <jacob@pfeifer.dev>
Co-authored-by: Borys Lykah <lykahb@fastmail.com>
2023-08-10 17:45:36 +08:00
Christian Clason
f060f03304
vim-patch:2eb413f89b97 (#24627)
* vim-patch:2eb413f89b97

detect filetype for `*.vsh` and `*.vv` files (vim/vim#12692)

Co-authored-by: Turiiya <34311583+tobealive@users.noreply.github.com>

2eb413f89b

Co-authored-by: Turiiya <34311583+ttytm@users.noreply.github.com>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2023-08-09 23:35:10 +02:00
Gregory Anders
2ee8ace217
fix(iter): make pipeline termination conditions consistent (#24614)
If an iterator pipeline stage returns nil as its first return value, the
other return values are ignored and it is treated as if that stage
returned only nil (the semantics of returning nil are different between
different stages). This is consistent with how for loops work in Lua
more generally, where the for loop breaks when the first return value
from the function iterator is nil (see :h for-in for details).
2023-08-09 15:41:45 -05:00
Christian Clason
3c929fd1c2
vim-patch:077ade4f6703 (#24629)
feat: recognize geojson extension as json filetype (vim/vim#12636)

077ade4f67

Co-authored-by: Dominique Pellé <dominique.pelle@gmail.com>
2023-08-09 22:35:57 +02:00
Christian Clason
2e8f38690f
vim-patch:b69b9d5e1753 (#24628)
Add filetype detection for eyaml files (vim/vim#12659)

https://github.com/voxpupuli/hiera-eyaml/ uses and produces the eyaml
format, which is simply yaml with some encrypted values.

It's convenient to edit the file without decrypting when not touching
encrypted values (or when you don't have access to the decryption key),
which is why vim should treat those files as yaml files.

b69b9d5e17

Co-authored-by: Max Gautier <mg@max.gautier.name>
2023-08-09 22:35:43 +02:00
Christian Clason
90ed7ee112
vim-patch:44ff25d5243b (#24625)
* vim-patch:44ff25d5243b

PyPA manifest files are not recognized (vim/vim#12707)

Problem:    PyPA manifest files are not recognized.
Solution:   Add a pattern to match PyPA manifest files.

44ff25d524

Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
2023-08-09 22:34:39 +02:00
Christian Clason
aaeb1a8cd1
vim-patch:7159ac7fec28 (#24624)
Unison support (vim/vim#12715)

7159ac7fec

Co-authored-by: Anton Parkhomenko <chuwy@users.noreply.github.com>
2023-08-09 22:34:02 +02:00
Christian Clason
ceb501c1c6
vim-patch:a13eb2b14791 (#24622)
Add WebGPU Shading Language (WGSL) filetype (vim/vim#12723)

The current W3C Working Draft for the WebGPU Shading Language (WGSL) specifies
'text/wgsl' media type for WGSL modules with the '.wgsl' file extension:
https://www.w3.org/TR/WGSL/#text-wgsl-media-type

It has also been registered at the Internet Assigned Numbers Authority (IANA):
https://www.iana.org/assignments/media-types/text/wgsl

Neovim's nvim-lspconfig already associates wgsl language servers
with 'filetype wgsl':
https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#wgsl_analyzer

However currenly setting 'filetype wgsl' for *.wgsl files by defalut in Neovim
is blocked by adding this filetype to the vim project first:
https://github.com/neovim/neovim/pull/23331

This commit adds this missing wgsl filetype.

a13eb2b147

Co-authored-by: Gergő Sályi <87373293+gergo-salyi@users.noreply.github.com>
2023-08-09 22:33:41 +02:00
bfredl
dbcba26bf1 fix(api): revert unintended change of optional bool params
Currently (as of nvim 0.9), the behavior of boolean params in
vim.api lua wrappers is inconsistent for optional parameters
(part of an `opts` dict) compared to positional parameters.

This was inadvertently changed in #24524 . While cleaning up this
inconsistency is something we might want eventually, it needs
to be discussed separately and the impact of existing code considered.
2023-08-09 20:34:07 +02:00
Christian Clason
c43c745a14
fix(lua): improve annotations for stricter luals diagnostics (#24609)
Problem: luals returns stricter diagnostics with bundled luarc.json
Solution: Improve some function and type annotations:

* use recognized uv.* types 
* disable diagnostic for global `vim` in shared.lua
* docs: don't start comment lines with taglink (otherwise LuaLS will interpret it as a type)
* add type alias for lpeg pattern
* fix return annotation for `vim.secure.trust`
* rename local Range object in vim.version (shadows `Range` in vim.treesitter)
* fix some "missing fields" warnings
* add missing required fields for test functions in eval.lua
* rename lsp meta files for consistency
2023-08-09 11:06:13 +02:00
zeertzjq
fdb11888f5
vim-patch:9.0.1679: Cleanup Tests from leftover files (#24617)
Problem:    Tests may leave leftover files around
Solution:   Clean up tests and remove files

There were a few failures in 'linux (huge, gcc, testgui, true, true)'
e.g. here: https://github.com/vim/vim/actions/runs/5497376153/jobs/10018060156

,----
| Error detected while processing command line..script /home/runner/work/vim/vim/src/testdir/runtest.vim[585]..function RunTheTest[54]..Test_lvimgrep_crash[16]..TestTimeout[12]..VimLeavePre Autocommands for "*"..function EarlyExit[7]..FinishTesting:
| line   70:
| E445: Other window contains changes
| E937: Attempt to delete a buffer that is in use: Xtest_stable_xxd.txt
| E937: Attempt to delete a buffer that is in use: Xtest_stable_xxd.txt
| E937: Attempt to delete a buffer that is in use: Xtest_stable_xxd.txtmalloc(): unsorted double linked list corrupted
`----

Which is puzzling, because the Xtest_stable_xxd file should have been
long gone after test_crypt.vim is run (and definitely no longer be
staying around in test_quickfix.vim).

So try to clean up properly after a test script is run, just in case any
X<file> is still around. During testing, a found a few leftover files,
which I also fixed in the relevant test-file.

Unfortunately, the test workflow 'linux (huge, gcc, testgui, true,
true)' now seems to fail with 'E1230: Encryption: sodium_mlock()' in
test_crypt.vim. Hopefully this is only temporary.

84bc00e9b5

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-08-09 06:07:23 +08:00
Lewis Russell
0211f889b9
fix(treesitter): make sure injections don't return empty ranges (#24595)
When an injection has not set include children, make sure not to add
the injection if no ranges are determined.

This could happen when there is an injection with a child that has the
same range as itself. e.g. consider this Makefile snippet

```make
foo:
  $(VAR)
```

Line 2 has an injection for bash and a make variable reference. If
include-children isn't set (default), then there is no range on line 2
to inject since the variable reference needs to be excluded.

This caused the language tree to return an empty range, which the parser
now interprets to mean the full buffer. This caused makefiles to have
completely broken highlighting.
2023-08-07 18:22:36 +01:00
ObserverOfTime
ce792db5b8
vim-patch:9.0.1678: blade files are not recognized (#24601)
Problem:    Blade files are not recognized.
Solution:   Add a pattern for Blade files. (closes vim/vim#12650)

ad34abee25

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-08-07 18:44:52 +02:00
bfredl
3a21c3afe6
Merge pull request #24524 from bfredl/typed_keys
refactor(api): use typed keysets
2023-08-07 14:42:25 +02:00
bfredl
0b351c3740 test(api): update tests to new error messages 2023-08-07 13:18:11 +02:00
bfredl
7bc93e0e2f refactor(api): use typed keysets
Initially this is just for geting rid of boilerplate,
but eventually the types could get exposed as metadata
2023-08-07 13:11:15 +02:00
zeertzjq
ef44e59729
fix(inccommand): don't set an invalid 'undolevels' value (#24575)
Problem:    Cannot break undo by setting 'undolevels' to itself in
            'inccommand' preview callback.
Solution:   Don't set an invalid 'undolevels' value.

Co-authored-by: Michael Henry <drmikehenry@drmikehenry.com>
2023-08-05 22:42:34 +08:00
Sean Dewar
cc87dda31a
fix(lsp): do not assume client capability exists in watchfiles check (#24550)
PR #23689 assumes `client.config.capabilities.workspace.didChangeWatchedFiles`
exists when checking `dynamicRegistration`, but thats's true only if it was
passed to `vim.lsp.start{_client}`.

This caused #23806 (still an issue in v0.9.1; needs manual backport), but #23681
fixed it by defaulting `config.capabilities` to `make_client_capabilities` if
not passed to `vim.lsp.start{_client}`.

However, the bug resurfaces on HEAD if you provide a non-nil `capabilities` to
`vim.lsp.start{_client}` with missing fields (e.g: not made via
`make_client_capabilities`).

From what I see, the spec says such missing fields should be interpreted as an
absence of the capability (including those indicated by missing sub-fields):
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#clientCapabilities

Also, suggest `vim.empty_dict()` for an empty dict in
`:h vim.lsp.start_client()` (`{[vim.type_idx]=vim.types.dictionary}`
no longer works anyway, probably since the cjson switch).
2023-08-04 08:10:54 +02:00
zeertzjq
3d3ec27d51
test(options/defaults_spec): fix NVIM_APPNAME test flakiness (#24553)
Also avoid leaving directories behind.
2023-08-04 10:37:47 +08:00
zeertzjq
21d466c1b9
fix(terminal): forward horizontal mouse scrolling (#24552) 2023-08-04 10:24:27 +08:00
zeertzjq
0a7fda6fa0
fix(terminal): include modifiers when forwarding mouse (#24549) 2023-08-04 09:34:13 +08:00
Tyler Miller
0804034c07
fix(loader): cache path ambiguity #24491
Problem: cache paths are derived by replacing each reserved/filesystem-
path-sensitive char with a `%` char in the original path. With this
method, two different files at two different paths (each containing `%`
chars) can erroneously resolve to the very same cache path in certain
edge-cases.

Solution: derive cache paths by url-encoding the original (path) instead
using `vim.uri_encode()` with `"rfc2396"`. Increment `Loader.VERSION` to
denote this change.
2023-08-01 08:28:28 -07:00
zeertzjq
c1c2a1b5dd
fix(inccommand): don't save information of a buffer twice (#24501)
Problem:    'inccommand' doesn't restore 'undolevels' properly for a
            buffer shown in multiple windows.
Solution:   Don't save information of a buffer twice.
2023-07-28 15:41:58 +08:00
Christian Clason
41cefe5130
build(deps): bump tree-sitter-c to v0.20.4 (#24495) 2023-07-27 12:45:08 +02:00
Sean Dewar
a47be0b2d9
fix(window): prevent win_size_restore from changing cmdheight
Currently it only skips if `Rows` changed, but it's possible for the height of
the usable area for windows to change (e.g: via `&ch`, `&stal` or `&ls`), which
can cause the value of `&cmdheight` to change when the sizes are restored.

This is a Vim bug, so I've submitted a PR there too. No telling when it'll be
merged though, given the current lack of activity there.

`ROWS_AVAIL` is convenient here, but also subtracts the `global_stl_height()`.
Not ideal, as we also care about the height of the last statusline for other
values of `&ls`. Meh.

Introduce `last_stl_height` for getting the height of the last statusline and
use it in `win_size_save/restore` and `last_status` (means
`last_status_rec`'s `statusline` argument will now be true if `&ls` is 3,
but that does not change the behaviour).

Also corrects the logic in `comp_col` to not assume there's a last statusline
if `&ls` is 1 and the last window is floating.
2023-07-26 20:44:46 +01:00
Sean Dewar
472271199e
feat(api): allow win_hide to close cmdwin or non-previous windows
This aligns its behaviour better with `nvim_win_close`.

Note that `:hide` is actually incapable of closing the cmdwin, unlike `:close`
and `:quit`, so this is a bit of a difference in behaviour.
2023-07-26 20:44:46 +01:00
Sean Dewar
5d921e28c1
feat(api): allow win_close in cmdwin to close wins except previous
Disallow closing the previous window from `nvim_win_close`, as this will cause
issues.

Again, no telling how safe this is. It also requires exposing old_curwin. :/

Also note that it's possible for the `&cmdheight` to change if, for example,
there are 2 tabpages and `nvim_win_close` is used to close the last window in
the other tabpage while `&stal` is 1. This is addressed in a later commit.
2023-07-26 20:44:46 +01:00
Sean Dewar
6b4970f6e0
feat(api): allow open_win/win_set_buf in the cmdwin in some cases
Problem: As discussed on Matrix, there was some interest in having
`nvim_open_win` again be able to open floats in the cmdwin (e.g: displaying a
hover doc related to what's in the cmdwin). After #23228, this was disallowed.

Solution: Allow `nvim_open_win` in the cmdwin as long as `!enter` and
`buffer != curbuf` (the former can cause all sorts of issues, and the latter
can crash Nvim after closing cmdwin). Also allow `nvim_win_set_buf` in a similar
fashion.

Note that we're not *entirely* sure if this is 100% safe (cmdwin is a
global-state-using-main-loop-calling beast), but this seems to work OK..?

Also:
  - Check the buffer argument of `nvim_open_win` earlier, and abort if it's
    invalid (it used to still open a window in this case).

  - Untranslate `e_cmdwin` errors in the API (other errors in the API are not
    translated: although not detailed in the API contract yet, errors are
    supposed to be stable).
2023-07-26 20:44:46 +01:00
zeertzjq
14d047ad2f
test(inccommand): add a test for #20248 (#24489) 2023-07-26 11:58:26 +08:00
Alexandre Teoi
643bea31b8
fix(inccommand): restrict cmdpreview undo calls (#24289)
Problem:
The cmdpreview saved undo nodes on cmdpreview_prepare() from ex_getln.c may
become invalid (free) if the preview function makes undo operations, causing
heap-use-after-free errors.

Solution:
Save the buffer undo list on cmdpreview_prepare)_ and start a new empty one. On
cmdpreview_restore_state(), undo all the entries in the new undo list and
restore the original one. With this approach, the preview function will be
allowed to undo only its own changes.

Fix #20036
Fix #20248
2023-07-26 11:22:57 +08:00
zeertzjq
aba3ceccb7
vim-patch:9.0.1335: no test for bad use of spaces in help files (#24483)
Problem:    No test for bad use of spaces in help files.
Solution:   Add checks for use of spaces in help files.  Ignore intentional
            spaces. (Hirohito Higashi, closes vim/vim#11952)

d950984489

Cherry-pick changes from patch 9.0.1604.

Co-authored-by: h-east <h.east.727@gmail.com>
Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-07-25 20:58:09 +08:00
Christoph Hasse
20c331915f
fix(lsp): SignatureHelp docstring is not escaped #16702
Problem:
Nvim LSP client always treats signature.documentation as markdown, even
if the server returns a plain string.
Per https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#signatureInformation
in a SignatureInformation response, the documentation field can be
either "string" or "MarkupContent".

Solution:
If signature.documentation is a string, treat it as "plaintext".

Closes #16563
2023-07-25 05:40:13 -07:00
zeertzjq
898384ac69
test(core/startup_spec): use retry() instead of jobwait() (#24481)
This should work on Windows.
2023-07-25 20:32:59 +08:00
zeertzjq
c0fa721ade
fix(startup): make recovery mode work without --headless (#24477) 2023-07-25 19:02:39 +08:00
zeertzjq
5fb4c397a1
fix(mouse): drag vsep of window with 'statuscolumn' (#24462)
Problem:    Cannot drag a vertical separator to the right of a window
            whose 'statuscolumn' is wider than itself.
Solution:   Never treat a click on a vertical separator as a click on
            'statuscolumn'.
2023-07-24 18:16:53 +08:00
zeertzjq
01e273c340
fix(statuscolumn): don't update clicks if current width is 0 (#24459) 2023-07-24 15:18:24 +08:00
zeertzjq
59289fb987
fix(highlight): make CurSearch work properly with 'winhl' (#24448) 2023-07-23 21:36:32 +08:00
zeertzjq
ce56ad2ba7
test: reduce flakiness (#24443)
Avoid consecutive RPC requests involving :startinsert or :stopinsert,
because consecutive RPC requests may be processed together, before the
:startinsert or :stopinsert takes effect.

Also change some feed_command() to command() to make tests faster.
2023-07-23 12:46:56 +08:00
zeertzjq
f56c184809
test: fix VimResume test flakiness (#24438) 2023-07-23 10:03:05 +08:00
zeertzjq
f0d618667a
test: check that TextChangedT cannot delete terminal buffer (#24437) 2023-07-23 08:53:59 +08:00
zeertzjq
cdb758ef44
test: check real cursor position in Terminal mode (#24436) 2023-07-23 08:23:07 +08:00
zeertzjq
a8cfdf43bc
fix(events): trigger VimResume on next UI request (#24426) 2023-07-23 07:16:41 +08:00
Lewis Russell
24e3ee9d07
fix(api/options): validate buf and win
Fixes #24398
2023-07-22 09:52:13 +01:00
zeertzjq
b74262a336
fix(terminal): send Shift-Home Shift-End Ctrl-Home Ctrl-End (#24418) 2023-07-22 08:00:42 +08:00
Justin M. Keyes
7907b1fca5 test(vim.ui.open): mock failure on Windows
Problem:
On Windows, `rundll32` exits zero (success) even when given
a non-existent file.

Solution:
Mock vim.system() on Windows to force a "failure" case.
2023-07-21 14:38:17 +02:00
zeertzjq
ca9f4a7cb1
docs: also change "vimL" and "viml" to "Vimscript" (#24414) 2023-07-21 16:30:05 +08:00
Brandon Simmons
58f9486144
fix(folds): update folds in Insert mode with fdm=indent (#24402)
Previously, when using foldmethod=indent, inserting an unindented line
would inadvertently open closed folds below it.
As a performance improvement, folds were only updated once, across all
lines, after Insert mode was exited.

Now, the performance improvement is no longer being used when
foldmethod=indent, so folds are updated multiple times during Insert
mode, but only across the lines that are changing, which preserves the
folds (and their open/close states) instead of recreating them.
2023-07-21 08:56:08 +08:00