Problem: vim_strnchr() is strange and unnecessary (after v9.1.1009)
Solution: Remove vim_strnchr() and use memchr() instead. Also remove a
comment referencing an #if that is no longer present.
vim_strnchr() is strange in several ways:
- It's named like vim_strchr(), but unlike vim_strchr() it doesn't
support finding a multibyte char.
- Its logic is similar to vim_strbyte(), but unlike vim_strbyte() it
uses char instead of char_u.
- It takes a pointer as its size argument, which isn't convenient for
all its callers.
- It allows embedded NULs, unlike other "strn*" functions which stop
when encountering a NUL byte.
In comparison, memchr() also allows embedded NULs, and it converts bytes
in the string to (unsigned char).
closes: vim/vim#1657934e1e8de91
Problem: getchar_spec may fail when screen:expect_unchanged() doesn't
wait long enough.
Solution: Add poke_eventloop() before screen:expect_unchanged().
Problem: 'diffopt' "linematch" cannot be used with {n} less than 10
digits (after v9.1.1022)
Solution: Fix off-by-one error when checking for digit (zeertzjq)
closes: vim/vim#16577ccd7f454fc
Problem: no sanitize check when running linematch
Solution: add sanitize check before applying the linematch algorithm,
similar to diff_find_change() (Jonathon)
closes: vim/vim#16446ca307efe48
Co-authored-by: Jonathon <jonathonwhite@protonmail.com>
Problem: Coverity complains about dereferencing NULL pointer
Solution: Verify curdiff is not null before dereferencing it
closes: vim/vim#16437a9f77be922
Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem: diff feature can be improved
Solution: include the linematch diff alignment algorithm
(Jonathon)
closes: vim/vim#96617c7a4e6d1a
Co-authored-by: Jonathon <jonathonwhite@protonmail.com>
Problem: Strange error when heredoc marker starts with "trim".
Solution: Check for whitespace after "trim" or "eval" (zeertzjq)
For :python3 etc., a heredoc marker that starts with a lower-case letter
is valid, and when it starts with "trim" it works in a script but not in
a function, and this PR makes it works in a function.
For :let, a heredoc marker that starts with a lower-case letter is not
valid, but when it starts with "trim" or "eval" the error can be a bit
confusing in a function, and this PR make it less confusing.
closes: vim/vim#16574449c2e5454
Problem: tests: test_compiler fails on Windows without Maven.
Solution: Add Xspotbugs directory to $PATH when mvn is not available
(zeertzjq).
closes: vim/vim#1657623da16d3d0
Problem: SpotBugs compiler can be improved
Solution: runtime(compiler): Improve defaults and error handling for
SpotBugs; update test_compiler.vim (Aliaksei Budavei)
runtime(compiler): Improve defaults and error handling for SpotBugs
* Keep "spotbugs#DefaultPreCompilerTestAction()" defined but
do not assign its Funcref to the "PreCompilerTestAction"
key of "g:spotbugs_properties": there are no default and
there can only be introduced arbitrary "*sourceDirPath"
entries; therefore, this assignment is confusing at best,
given that the function's implementation delegates to
whatever "PreCompilerAction" is.
* Allow for the possibility of relative source pathnames
passed as arguments to Vim for the Javac default actions,
and the necessity to have them properly reconciled when
the current working directory is changed.
* Do not expect users to remember or know that new source
files ‘must be’ ":argadd"'d to be then known to the Javac
default actions; so collect the names of Java-file buffers
and Java-file Vim arguments; and let users providing the
"@sources" file-lists in the "g:javac_makeprg_params"
variable update these file-lists themselves.
* Strive to not leave behind a fire-once Syntax ":autocmd"
for a Java buffer whenever an arbitrary pre-compile action
errors out.
* Only attempt to run a post-compiler action in the absence
of failures for a pre-compiler action. Note that warnings
and failures are treated alike (?!) by the Javac compiler,
so when previews are tried out with "--enable-preview",
remember about passing "-Xlint:-preview" too to also let
SpotBugs have a go.
* Properly group conditional operators when testing for key
entries in a user-defined variable.
* Also test whether "javaExternal" is defined when choosing
an implementation for source-file parsing.
* Two commands are provided to toggle actions for buffer-local
autocommands:
- SpotBugsRemoveBufferAutocmd;
- SpotBugsDefineBufferAutocmd.
For example, try this from "~/.vim/after/ftplugin/java.vim":
------------------------------------------------------------
if exists(':SpotBugsDefineBufferAutocmd') == 2
SpotBugsDefineBufferAutocmd BufWritePost SigUSR1
endif
------------------------------------------------------------
And ":doautocmd java_spotbugs User" can be manually used at will.
closes: vim/vim#16140368ef5a48c
Co-authored-by: Aliaksei Budavei <0x000c70@gmail.com>
Problem:
's 'guicursor' cursor color not working in suckless terminal (ST).
Nvim's builtin terminfo for ST lacks a "Cs" entry, even though ST does
support the cursor color to be set via termcodes.
Solution:
- In `augment_terminfo()`, assume that `st` always supports color cursor.
- Thomas Dickey will add a "Cs" entry for st to ncurses, from which
Nvim's builtin terminfos are generated.
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
Problem: "clear" macros are not always used.
Solution: Use ALLOC_ONE, VIM_CLEAR, CLEAR_POINTER and CLEAR_FIELD in more
places. (Yegappan Lakshmanan, closesvim/vim#12104)
960dcbd098
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Problem: Cannot use Perl heredoc in nested :def function. (Virginia
Senioria)
Solution: Only concatenate heredoc lines when not in a nested function.
(closesvim/vim#10415)
d881d15984
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Arguments of a function are missing after failing to redefine
it (after 8.2.2505), and heap-use-after-free with script-local
function (after 9.1.1063).
Solution: Don't clear arguments or free uf_name_exp when failing to
redefine an existing function (zeertzjq)
closes: vim/vim#1656704d2a3fdc0
Problem: heap-use-after-free and stack-use-after-scope with :14verbose
when using :return and :try (after 9.1.1063).
Solution: Move back the vim_free(tofree) and the scope of numbuf[].
(zeertzjq)
closes: vim/vim#165632101230f40
Problem: too many strlen() calls in userfunc.c
Solution: refactor userfunc.c and remove calls to strlen(),
drop set_ufunc_name() and roll it into alloc_ufunc(),
check for out-of-memory condition in trans_function_name_ext()
(John Marriott)
closes: vim/vim#16537b32800f7c5
Add missing change to call_user_func() from patch 8.1.1007.
Consistently use PRIdSCID instead of PRId64 for script IDs.
Co-authored-by: John Marriott <basilisk@internode.on.net>
Problem: Crash and/or memory leak when redefining function after error.
Solution: Clear pointer after making a copy. Clear arrays on failure.
(closesvim/vim#11774)
f057171d8b
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Vim9: function expanded name is cleared when sourcing a script
again.
Solution: Only clear the expanded name when deleting the function.
(closesvim/vim#6707)
c4ce36d486
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: def_function() may return pointer that was freed.
Solution: Set "fp" to NULL after freeing it.
a14e697547
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Cannot control cursor positioning of getchar().
Solution: Add "cursor" flag to {opts}, with possible values "hide",
"keep" and "msg".
related: vim/vim#10603closes: vim/vim#16569edf0f7db28
Problem:
When an evaluation {-item calls `nvim_eval_statusline()`, that nested
call may overwrite the same memory used for `stl_items`.
Solution:
Make `curitem` static and use it to compute an offset to avoid
overwriting `stl_items` in nested calls to `build_stl_str_hl()`. Move
miscellaneous statusline tests into `describe()` block.
When given, only that range will be checked for validity rather than the
entire tree. This is used in the highlighter to save CPU cycles since we
only need to parse a certain region at a time anyway.
This means that all work previously done by a `_parse()` iteration will
be kept in future iterations. This prevents it from running indefinitely
in some cases where the file is very large and there are 2+ injections.
Problem:
When running an initial parse, parse() returns an empty table rather
than an actual range. In `languagetree.lua`, we manually check if
a parse was incremental to determine the changed parse region.
Solution:
- Always return a range (in the C side) from parse().
- Simplify the language tree code a bit.
- Logger no longer shows empty ranges on the initial parse.
This simplifies some logic in `languagetree.lua`, removing the need for
`_has_regions`, and removing side effects in `:included_regions()`.
Before:
- Edit is made which sets `_regions = nil`
- Upon the next call to `included_regions()` (usually right after we
marked `_regions` as `nil` due to an `_iter_regions()` call), if
`_regions` is nil, we repopulate the table (as long as the tree
actually has regions)
After:
- Edit is made which resets `_regions` if it exists
- `included_regions()` no longer needs to perform this logic itself, and
also no longer needs to read a `_has_regions` variable
Compute the diagnostics per line when `show` is called, allowing for
O(1) access for the diagnostics to display when the cursor line or the
list of diagnostics haven't changed.
Before the 7121983c45 refactoring this
loop added highlights from a `buf_hls` list that had filtered out
elements with `Attrs.None`. After the refactoring this added highlights
from `hls` directly, and those elements would fail with e.g.:
$ nvim 'man://math.h(0)'
Error detected while processing command line:
Error executing Lua callback: /usr/share/nvim/runtime/lua/man.lua:205: Invalid 'hl_group': Expected Lua string
stack traceback:
[C]: in function 'nvim_buf_add_highlight'
/usr/share/nvim/runtime/lua/man.lua:205: in function 'highlight_man_page'
/usr/share/nvim/runtime/lua/man.lua:632: in function 'init_pager'
/usr/share/nvim/runtime/plugin/man.lua:9: in function </usr/share/nvim/runtime/plugin/man.lua:6>
Problem: preinsert text completions not deleted with <C-W>/<C-U>
(ddad431, after v9.1.1059)
Solution: handle <C-W> or <C-U> specifically and clear the completion
(glepnir)
fixes: vim/vim#16557closes: vim/vim#16565001c26cd61
Problem:
The current implementation uses a global augroup for virtual lines in
diagnostics, which can lead to conflicts and unintended behavior when
multiple namespaces/buffers are involved.
Solution:
Refactor the code to use a namespace-specific augroup for virtual lines.
This ensures that each namespace has its own augroup.
Scope the clear commands to only the relevant buffer.
Problem: getchar() can't distinguish between C-I and Tab.
Solution: Add {opts} to pass extra flags to getchar() and getcharstr(),
with "number" and "simplify" keys.
related: vim/vim#10603closes: vim/vim#16554e0a2ab397f
Cherry-pick tv_dict_has_key() from patch 8.2.4683.
Problem:
`AucmdExecutable` adds 2 layers of indirection. Although formalizing
a `union` is good practice for shared interfaces, this struct is mainly
for `autocmd_register` which is internal to this module.
Solution:
- Store the cmd/fn fields directly on the `AutoCmd` struct.
- Drop `AucmdExecutable` and related structures.
Port one_function_arg() and get_function_body() from Vim.
vim-patch:8.2.2865: skipping over function body fails
Problem: Skipping over function body fails.
Solution: Do not define the function when skipping.
d87c21a918
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem:
Event handler declared with `once=true` can re-trigger itself (i.e. more
than once!) by calling `nvim_exec_autocmds` or `:doautocmd`.
Analysis:
This happens because the callback is executed before deletion/cleanup
(`aucmd_del`). And calling `aucmd_del` before `call_autocmd_callback`
breaks the autocmd execution...
Solution:
Set `ac->pat=NULL` to temporarily "delete" the autocmd, then restore it
after executing the callback.
Fix#25526
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>