Commit Graph

22725 Commits

Author SHA1 Message Date
bfredl
f1ea126a6e
Merge pull request #19906 from bfredl/bigstage
perf(api): allow to use an arena for return values
2022-08-24 15:22:30 +02:00
zeertzjq
f91b1885dd
feat(eval)!: make Vim functions return inner window width and height (#19743)
In non-multigrid UI the only change is that the returned height now
excludes winbar, and this is compatible with Vim.

In multigrid UI this means the return value of these functions now
reflect the space available for buffer lines in a window.

No change in nvim_win_get_height() and nvim_win_get_width().
2022-08-24 21:02:45 +08:00
zeertzjq
b0fdce55d0
vim-patch:partial:8.2.3953: insert completion code is too complicated (#19923)
Problem:    Insert completion code is too complicated.
Solution:   More refactoring.  Move function arguments into a struct.
            (Yegappan Lakshmanan, closes vim/vim#9437)
6ad84ab3e4

Skip most pum-related refactoring.
Cherry-pick rename to match_at_original_text() from patch 8.2.4001.
2022-08-24 20:36:10 +08:00
bfredl
7784dc9e0d refactor(api): provide a temporary copy solution for nvim_call_atomic
Make the copy_object() family accept an optional arena. More than
half of the callsites should be refactored to use an arena later
anyway.
2022-08-24 14:22:26 +02:00
bfredl
bcf5ee328e refactor(arena): use a shared block freelist
This is both simpler in client code and more effective (always reuse
block hottest in cache)
2022-08-24 14:22:26 +02:00
zeertzjq
b0569f5813
vim-patch:9.0.0020: with some completion reading past end of string (#19922)
Problem:    With some completion reading past end of string.
Solution:   Check the length of the string.
f12129f171
2022-08-24 16:59:03 +08:00
zeertzjq
79f32c20f0
Merge pull request #19921 from zeertzjq/vim-8.2.3937
vim-patch:8.2.{3937,3944}: Insert mode completion refactoring
2022-08-24 16:12:15 +08:00
zeertzjq
9ac44c7f5d vim-patch:8.2.3944: insert mode completion functions are too long
Problem:    Insert mode completion functions are too long.
Solution:   Split up into multiple functions. (Yegappan Lakshmanan,
            closes vim/vim#9431)
5d2e007ccb

Cherry-pick can_cindent_get() -> get_can_cindent() from patch 8.1.2062.
2022-08-24 15:47:15 +08:00
zeertzjq
ef748af01d vim-patch:8.2.3937: Insert mode completion function is too long
Problem:    Insert mode completion function is too long.
Solution:   Refactor into multiple functions. (Yegappan Lakshmanan,
            closes vim/vim#9423)
edc6f10390

Cherry-pick a typo fix from patch 8.2.3637.
2022-08-24 15:47:14 +08:00
sigmaSd
a4e4609d62
fix(path): path_is_url returns false for "foo:/" #19797
Problem:
path_to_url() returns false for single-slash URIs ("foo:/" vs "foo://").
This is not compliant with the URI spec. https://url.spec.whatwg.org/#url-representation
LSP in particular allows single-slash URIs.

Solution:
Relax path_to_url() to accept single-slash URIs. This is not fully
compliant (only ":" is required by the spec), but it is hopefully good
enough without causing false-positives in typical text files.

ref https://url.spec.whatwg.org/#windows-drive-letter
ref https://github.com/neovim/neovim/pull/19773
ref https://github.com/neovim/neovim/pull/19773#issuecomment-1214763769
2022-08-23 23:38:06 -07:00
zeertzjq
9a100ee169
fix(cmdline): do not trigger completion at wrong time (#19920)
Cherry-picked from Vim patches 8.2.4339, 9.0.0238.
2022-08-24 10:28:32 +08:00
zeertzjq
64d147b471
vim-patch:9.0.0248: duplicate code in finding a script in the execution stack (#19917)
Problem:    Duplicate code in finding a script in the execution stack.
Solution:   Reduce duplicate code. (closes vim/vim#10961)
a247142ae4
2022-08-24 06:28:37 +08:00
bfredl
c0d6052654 perf(api): allow to use an arena for return values 2022-08-23 18:34:24 +02:00
zeertzjq
6cc6e11929
vim-patch:9.0.0206: redraw flags are not named specifically (#19913)
Problem:    Redraw flags are not named specifically.
Solution:   Prefix "UPD_" to the flags, for UPDate_screen().
a4d158b3c8
2022-08-23 22:00:19 +08:00
Lewis Russell
779a25f040
refactor(spell.c): resolve clint errors (#19875)
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2022-08-23 14:30:02 +01:00
Lewis Russell
0c0a426e40
doc(CONTRIBUTING): update #19891
- add section for managing includes via IWYU
- recommend clangd over ctags
- tidy up links
- remove ./scripts/check-includes.py
2022-08-23 06:18:05 -07:00
Simon Wachter
e892b7b383
fix(inspect): escape identifiers that are lua keywords (#19898)
A lua keyword is not a valid table identifier
2022-08-23 13:02:55 +02:00
zeertzjq
df4709ddf6
Merge pull request #19905 from zeertzjq/vim-8.2.4726
vim-patch:8.2.{4726,4740,4741,4749,4841,4842}: expand('<script>')
2022-08-23 18:12:28 +08:00
zeertzjq
d459b66877 vim-patch:8.2.4842: expand("%:p") is not empty when there is no buffer name
Problem:    expand("%:p") is not empty when there is no buffer name.
Solution:   When ignoring errors still return NULL. (closes vim/vim#10311)
211a5bb235
2022-08-23 17:48:12 +08:00
zeertzjq
f1b8683b8c vim-patch:8.2.4841: empty string considered an error for expand()
Problem:    Empty string considered an error for expand() when 'verbose' is
            set. (Christian Brabandt)
Solution:   Do not give an error for an empty result. (closes vim/vim#10307)
a96edb736d
2022-08-23 17:48:12 +08:00
zeertzjq
d0b9fe2d5a vim-patch:8.2.4749: <script> is not expanded in autocmd context
Problem:    <script> is not expanded in autocmd context.
Solution:   Add the context to the pattern struct. (closes vim/vim#10144)
            Rename AutoPatCmd to AutoPatCmd_T.
eca7c60d68

Omit AutoPatCmd -> AutoPatCmd_T rename as it is inconsistent.
Use `.sn_name` instead of `->sn_name` as v8.2.0154 hasn't been ported.
Omit acp_script_stx(), use member directly.
2022-08-23 17:48:12 +08:00
zeertzjq
7afc17dec1 vim-patch:8.2.4741: startup test fails
Problem:    Startup test fails.
Solution:   Avoid an error for verbose expansion.  Fix that the "0verbose"
            command modifier doesn't work.
60895f3e36

Most code changes has already been ported.
2022-08-23 17:48:12 +08:00
zeertzjq
a9e6cf0e64 vim-patch:8.2.4740: when expand() fails there is no error message
Problem:    When expand() fails there is no error message.
Solution:   When 'verbose' is set give an error message.
575445200b
2022-08-23 17:48:12 +08:00
zeertzjq
ffa1335047 vim-patch:8.2.4726: cannot use expand() to get the script name
Problem:    Cannot use expand() to get the script name.
Solution:   Support expand('<script>'). (closes vim/vim#10121)
6013d0045d

Use `.sn_name` instead of `->sn_name` as v8.2.0154 hasn't been ported.
Cherry-pick builtin.txt expand() doc from latest Vim.
2022-08-23 17:47:46 +08:00
zeertzjq
42e9fe7d95
test: add test for using :normal to stop Visual mode in cmdwin (#19904) 2022-08-23 11:39:25 +08:00
zeertzjq
63df91c10a
vim-patch:8.2.1046: insufficient tests for src/buffer.c (#19903)
Problem:    Insufficient tests for src/buffer.c.
Solution:   Add more tests.  Move comments related tests to a separate file.
            (Yegappan Lakshmanan, closes vim/vim#6325)
b7e2483655
2022-08-23 11:24:46 +08:00
zeertzjq
d5328ea408
vim-patch:8.2.0522: several errors are not tested for (#19901)
Problem:    Several errors are not tested for.
Solution:   Add tests. (Yegappan Lakshmanan, closes vim/vim#5892)
ee4e0c1e9a

Omit Test_range() change: reverted in patch 8.2.0615.
Cherry-pick Test_z_no_space_before_xxx() from patch 8.2.0195.
Cherry-pick Test_reverse_sort_uniq() change from patch 8.2.0183.
Make uniq() error behavior consistent with sort().
Cherry-pick Test_set_ttytype() change from patch 8.1.1826.
Cherry-pick quickfix checks from patch 8.1.2373 to test_preview.vim.
Test_viminfo_error() is applicable.
Cherry-pick E1058 from patch 8.2.0149 and port Test_deep_nest() to Lua.
2022-08-23 10:38:53 +08:00
zeertzjq
48a4657aee
vim-patch:8.1.{1915,1921,1953} (#19900)
vim-patch:8.1.1915: more functions can be used as methods

Problem:    More functions can be used as methods.
Solution:   Make various functions usable as a method.
1a3a89168d

Move debugbreak() to the right place.

vim-patch:8.1.1921: more functions can be used as methods

Problem:    More functions can be used as methods.
Solution:   Make various functions usable as a method.
a4208966fb

vim-patch:8.1.1953: more functions can be used as a method

Problem:    More functions can be used as a method.
Solution:   Allow more functions to be used as a method.
f9f24ce7a0

Omit test_termcodes.vim: cannot be used and superseded by later patches.
Cherry-pick test_bufline.vim change from patch 8.1.1993.
2022-08-23 08:36:22 +08:00
zeertzjq
2fd25fb909
vim-patch:8.1.0832: confirm() is not tested (#19896)
Problem:    confirm() is not tested.
Solution:   Add a test. (Dominique Pelle, closes vim/vim#3868)
2e05009218
2022-08-23 07:20:23 +08:00
zeertzjq
baaaa1f2b3
vim-patch:8.2.3421: a bit of code is not covered by tests (#19895)
Problem:    A bit of code is not covered by tests.
Solution:   Add a few more test cases. (Dominique Pellé, closes vim/vim#8857)
d176ca3dde

Cherry-pick Test_trim() change from patch 8.2.0448.
Cherry-pick Test_History() change from patch 8.2.1736.
Cherry-pick charidx() and trim() type checks from patch 8.2.3135.
2022-08-22 22:09:53 +08:00
zeertzjq
15a768eeb0
fix(api): avoid side effects with nvim_parse_cmd (#19890)
Save and restore the cursor and last search pattern and do not change
search history.
2022-08-22 18:06:18 +08:00
zeertzjq
2bed0d1d97
vim-patch:8.2.4753: error from setting an option is silently ignored (#19888)
Problem:    Error from setting an option is silently ignored.
Solution:   Handle option value errors better.  Fix uses of N_().
31e5c60a68
2022-08-22 13:56:50 +08:00
Axel Forsman
d4d27c41b3
fix(edit.c): indentkeys double indent after "!" #12894
which is both unexpected and different from the Vim behaviour.

Indent was triggered once by the '!' check in insert_execute(), and
inserting the char was correctly skipped, but then triggered again in
insert_check() (provided that cindent was not being ignored after manual
indentation, i.e. `can_cindent == true`).

While this is the smallest fix, another solution would be to remove
VimState#check and instead move that to *_enter()/-_execute(), since the
control flow is pretty unnecessarily convoluted as is. That would also
have the benefit of differing less from the Vim source code.
2022-08-21 21:48:18 -07:00
zeertzjq
4f6d0d6da9
vim-patch:8.2.2289: Vim9: 'cpo' can become empty (#19887)
Problem:    Vim9: 'cpo' can become empty.
Solution:   Use empty_option instead of an empty string.  Update quickfix
            buffer after restoring 'cpo'.  (closes vim/vim#7608)
e5a2dc87fd

Omit test as it is Vim9 script.
2022-08-22 12:02:45 +08:00
zeertzjq
d5cc161dea
Merge pull request #19886 from zeertzjq/vim-8.2.2030
vim-patch:8.2.{2030,2031}: some tests fail
2022-08-22 10:15:00 +08:00
zeertzjq
b94cfaf080 vim-patch:8.2.2031: some tests fail when run under valgrind
Problem:    Some tests fail when run under valgrind.
Solution:   Avoid timing problems.
18dc355395
2022-08-22 09:53:09 +08:00
zeertzjq
af2b078258 vim-patch:8.2.2030: some tests fail on Mac
Problem:    Some tests fail on Mac.
Solution:   Avoid Mac test failures.  Add additional test for wildmenu.
            (Yegappan Lakshmanan, closes vim/vim#7341)
4b2ce1297e
2022-08-22 09:53:07 +08:00
zeertzjq
72b03792b6
Merge pull request #19885 from zeertzjq/vim-8.2.4328
vim-patch:8.2.{4328,4334}: wildmenu tests
2022-08-22 09:27:55 +08:00
zeertzjq
06a53ab2cb vim-patch:8.2.4334: command line popup menu not positioned correctly
Problem:    Command line popup menu not positioned correctly.
Solution:   Also use vim_strsize() on the existing text. (Naruhiko Nishino,
            closes vim/vim#9727)
68cc2b8a37
2022-08-22 09:08:47 +08:00
zeertzjq
99bd895956 vim-patch:8.2.4328: command line complete matches cleard when typing character
Problem:    Command line complete matches cleard when typing character.
            (Dominique Pellé)
Solution:   Only remove a popup menu if there is one.
73a16c22a4
2022-08-22 08:55:54 +08:00
bfredl
c086bf6079
Merge pull request #19864 from lewis6991/decorfix
fix(ui): don't allow decor provider with ns_id==0
2022-08-21 21:11:56 +02:00
zeertzjq
2379699b1e
vim-patch:9.0.0236: popup menu not removed when 'wildmenu' reset while visible (#19882)
Problem:    Popup menu not removed when 'wildmenu' reset while it is visible.
Solution:   Do not check p_wmnu, only pum_visible(). (closes vim/vim#10953)
b82a2ab8ad
2022-08-21 22:03:26 +08:00
zeertzjq
e3eb6967bc
vim-patch:8.2.4325: 'wildmenu' only shows few matches (#19876)
Problem:    'wildmenu' only shows few matches.
Solution:   Add the "pum" option: use a popup menu to show the matches.
            (Yegappan Lakshmanan et al., closes vim/vim#9707)
3908ef5017

Omit p_wmnu check in cmdline_pum_active() as it can cause problems.
Omit vim_strchr() flags as that isn't really better than bitmasks.
Omit key translations and document it in vim_diff.txt.
2022-08-21 21:31:25 +08:00
Javier Lopez
dde90f0ca4
fix(api/command): fargs behavior when no arguments are passed (#19862)
Problem: A command defined with `nargs="?"` returns `fargs={""}` to
a Lua callback when executed with no arguments, which is inconsistent
with how`nargs="*"` behaves.

Solution: Pass `fargs={}` for no argument with `nargs="?"` as well.
2022-08-21 15:19:29 +02:00
zeertzjq
5928d5c2f1
vim-patch:9.0.0234: cannot make difference between :normal end and argument char (#19879)
Problem:    Cannot make difference between the end of :normal and a character
            in its argument.
Solution:   Add the "typebuf_was_empty" flag. (closes vim/vim#10950)
8d69637133
2022-08-21 19:37:11 +08:00
zeertzjq
6b9852cc41
vim-patch:8.2.4754: using cached values after unsetting some environment variables (#19872)
Problem:    Still using cached values after unsetting some known environment
            variables.
Solution:   Take care of the side effects. (closes vim/vim#10194)
7714231bb5

Cherry-pick vim_setenv_ext() from patch 8.2.0200.
2022-08-21 11:37:13 +08:00
zeertzjq
506a3ec913
refactor: make wildmenu code closer to Vim (#19870)
This is a small refactor that makes `compl_match_array` static and
doesn't change any behavior.
2022-08-21 11:06:07 +08:00
zeertzjq
61ff37952a
vim-patch:8.2.1587: loop for handling keys for the command line is too long (#19868)
Problem:    Loop for handling keys for the command line is too long.
Solution:   Move wild menu handling to separate functions. (Yegappan
            Lakshmanan, closes vim/vim#6856)
eadee486c7
2022-08-21 09:18:47 +08:00
zeertzjq
741ef87876
vim-patch:8.1.1914: command line expansion code is spread out (#19867)
Problem:    Command line expansion code is spread out.
Solution:   Move set_one_cmd_context(). (Yegappan Lakshmanan, closes vim/vim#4855)
d019039ccd
2022-08-21 08:05:39 +08:00
zeertzjq
76d35a5a36
vim-patch:9.0.0231: expanding "**" may loop forever with directory links (#19866)
Problem:    Expanding "**" may loop forever with directory links.
Solution:   Check for being interrupted. (closes vim/vim#10946)
57e95179ab
2022-08-21 07:08:09 +08:00