Problem: possible crash when calculating topline in diff.c
(youngmith)
Solution: Check for pointer being Null before accessing it
fixes: vim/vim#18437d32b3bb7eb
The POC is likely not applicable to Nvim due to #32160.
Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem: Vim tests are slow and flaky at the same time due to reliance
on timeouts which are unreliable.
Solution: improve Vim test performance and reduce flakiness
(Yee Cheng Chin)
A lot of Vim tests currently rely on waiting a specific amount of time
before asserting a condition. This is bad because 1) it is slow, as the
timeout is hardcoded, 2) it's unreliable as a resource-starved runner
may overshoot the timeout. Also, there are a lot of builtin sleep
commands in commonly used utilities like VerifyScreenDump and WaitFor()
which leads to a lot of unnecessary idle time.
Fix these issues by doing the following:
1. Make utilities like VerifyScreenDump and WaitFor use the lowest wait
time possible (1 ms). This essentially turns it into a spin wait. On
fast machines, these will finish very quickly. For existing tests
that had an implicit reliance on the old timeouts (e.g.
VerifyScreenDump had a 50ms wait before), fix the tests to wait that
specific amount explicitly.
2. Fix tests that sleep or wait for long amounts of time to instead
explicitly use a callback mechanism to be notified when a child
terminal job has finished. This allows the test to only take as much
time as possible instead of having to hard code an unreliable
timeout.
With these fixes, tests should 1) completely quickly on fast machines,
and 2) on slow machines they will still run to completion albeit slowly.
Note that previoulsy both were not true. The hardcoded timeouts meant
that on fast machines the tests were mostly idling wasting time, whereas
on slow machines, the timeouts often were not generous enough to allow
them to run to completion.
closes: vim/vim#16615e70587dbdb
Part of shared.vim and test_crash.vim changes only.
Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
Fixes#35884
Problem: Since `once_buf_loaded` might call a callback passed to it at a
later point (which is it's reason to exist) that callback might end up
referring to stale diagnostics in a handler's `show` function. For
example, if we first call `vim.diagnostic.set` for an unloaded buffer,
then call `vim.diagnostic.reset` and only then load the buffer, we might
still see diagnostics from `vim.diagnostic.set` call, which are stale at
this point.
Solution: only keep one autocommand from the most reset `show` call and
delete it when `hide` is called.
**Problem(?):** Buffers that (for whatever reason) aren't meant to have
a final newline are still parsed with a final newline in `treesitter.c`.
**Solution:** Don't add the newline to the last buffer line if it
shouldn't be there. (This more closely matches the approach of
`read_buffer_into()`.)
This allows us to, say, use a scratch buffer with `noeol` and `nofixeol`
behind the scenes in `get_string_parser()`.
...which would allow us to track injection trees with extmarks in that
case.
...which would allow us to not drop previous trees after reparsing a
different range with `get_parser():parse()`.
...which would prevent flickering when editing a buffer that has 2+
windows to it in view at a time.
...which would allow us to keep our sanity!!!
(one step at a time...)
Problem: tests: "Untitled" file not removed when running Test_crash1_3 alone
with TEST_FILTER (after v9.1.0695)
Solution: Use a TearDown function instead of another test.
(zeertzjq)
closes: vim/vim#15578closes: vim/vim#15577d56c451e1c
Problem: tests: test_crash leaves Untitled file around
Solution: cleanup at the end of the test_crash.vim test file
cd83173def
Co-authored-by: Christian Brabandt <cb@256bit.org>
Problem: buffer-overflow in do_search() with 'rightleft'
(SuyueGuo)
Solution: after reversing the text (which allocates a new buffer),
re-calculate the text length
Github Advisory:
https://github.com/vim/vim/security/advisories/GHSA-v2x2-cjcg-f9jmcacb6693c1
Add missing change from patch 8.1.1270.
Omit `call delete('Untitled')`: moved again in patch 9.1.0695.
Co-authored-by: Christian Brabandt <cb@256bit.org>
The current description (especially the "unlimited width" part) is
inaccurate in several ways:
- The size of virtual text can depend on window width. In particular,
the size of "above" virtual text can be equal to window width.
- A double-width character that doesn't fit adds 1 to the virtual column
of the following characters.
- The size of 'showbreak' and 'breakindent' is counted.
related: vim/vim#5713closes: vim/vim#18447014c731fa5
Problem:
Autocmds in inline_completion Completor are not scoped to specific
buffers. When multiple buffers have inline completion enabled, events
(InsertEnter, CursorMovedI, TextChangedP, InsertLeave) in any buffer
trigger callbacks for all Completor instances, causing incorrect
behavior across buffers.
Solution:
Add `buffer = bufnr` parameter to nvim_create_autocmd() calls to make
them buffer-local. Each Completor instance now only responds to events
in its own buffer.
Problem: Marks are lost after `:bdelete` because `ignore_buf()` filters
out unlisted buffers during shada mark processing.
Solution: Revert to original buffer checks for mark operations, avoiding
`!buf->b_p_bl` condition that incorrectly ignores deleted buffers.
Problem: completion: "longest" doesn't work for manual completion when
'autocomplete' is on (after 9.1.1800).
Solution: Only reset compl_get_longest when enabling autocompletion
(zeertzjq).
closes: vim/vim#18430b3966d6a8e
Change the second "if" to "because", otherwise it may be misinterpreted
that preinserted() can return non-zero just because these options are
set.
closes: vim/vim#184094edaf89233
Problem: completion: autocompletion can be improved
Solution: Add support for "longest" and "preinsert" in 'autocomplete';
add preinserted() (Girish Palya)
* Add support for "longest" in 'completeopt' when 'autocomplete'
is enabled. (Note: the cursor position does not change automatically
when 'autocomplete' is enabled.)
* Add support for "preinsert" when 'autocomplete' is enabled. Ensure
"preinsert" works the same with and without 'autocomplete'
* introduce the preinserted() Vim script function, useful for defining
custom key mappings.
fixes: vim/vim#18314closes: vim/vim#18387c05335082a
Co-authored-by: Girish Palya <girishji@gmail.com>
Problem: tex syntax file does not support some of the math equation
environments provided by amsmath.sty, therefore well-formed
snippet is highlighted as "texBadMath"
Solution: add the environments
closes: vim/vim#1843305e44e978f
Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
Problem: Option insecure flags not copied when splitting window.
Solution: Move window-local insecure flags to winopt_T and copy them
properly (zeertzjq).
closes: vim/vim#18434b3740f4b00
Problem: :set doesn't clear local insecure flag like :setlocal does.
Solution: Also clear the local insecure flag when using :set (zeertzjq).
This applies to local options like 'wrap', 'foldtext' and 'foldexpr',
whose global flags are actually never used. For global-local options
like 'statusline' the behavior is already correct, so add some tests.
related: vim/vim#18434fec5586a45
- Match comments after Vim9 :echo and :execute.
- Match comments after Vim9 and legacy :eval.
closes: vim/vim#18420f4a6acd86e
Co-authored-by: Doug Kearns <dougkearns@gmail.com>
Include post operator whitespace in the Vim9 variable assignment
lookahead so that "redir =>" doesn't match as an assignment.
fixes: vim/vim#18319closes: vim/vim#1832357d243e27d
Co-authored-by: Doug Kearns <dougkearns@gmail.com>
Problem: 'nowrap' in a modeline may hide malicious code.
Solution: Forcibly use '>' as 'listchars' "extends" if 'nowrap' was set
from a modeline (zeertzjq).
Manual `:setlocal nowrap` disables this behavior. There is a separate
problem with `:set nowrap` that also applies to some other options.
related: vim/vim#18214
related: vim/vim#18399closes: vim/vim#184259d5208a931
Cherry-pick some test_modeline.vim changes from patches 9.0.{0363,0626}.
Problem: :update should write new file buffers, but previous fix
affected special buffer types (acwrite, nofile, etc.).
Solution: Add bt_nofilename() check to only write new files for
buffers representing real filesystem paths.
`runtime/indent/Makefile` was removed in 2d8ed73, and now `make clean`
and `make distclean` fail since those jobs call `make -C runtime/indent
clean`
Remove call to `make -C runtime/indent clean`