Problem: TUI flush (start sync or hide cursor) only starts on a "flush"
event, which is too late.
Solution: Start the next flush when anything will be drawn.
Problem: Currently, `get_option_value()` returns 3 separate things: The actual value of the option, whether the option is hidden, and the option flags. This makes the function difficult to refactor, modify or otherwise reason about.
Solution: Split `get_option_value()` into 3 functions, each with a single purpose. This also affects `get_option_value_for()`.
When we convert a Lua table to an Object, we consider the table a
"dictionary" if it contains only string keys, and an array if it
contains all numeric indices with no gaps. While rare, Lua tables can
have both strictly numeric indices and gaps (e.g. { [2] = 2 }). These
currently cannot be serialized because it is not considered an array.
However, we know the maximum index of the table and as long as all of
the keys in the table are numeric, it is still possible to serialize
this table as an array. The missing indices will have nil values.
Problem: The entire marktree needs to be traversed each time a sign is
removed from the sentinel line.
Solution: Remove sentinel line and instead keep track of the number of
lines that hold up the 'signcolumn' in "max_count". Adjust this
number for added/removed signs, and set it to 0 when the
maximum number of signs on a line changes. Only when
"max_count" is decremented to 0 due to sign removal do we need
to check the entire buffer.
Also replace "invalid_top" and "invalid_bot" with a map of
invalid ranges, further reducing the number of lines to be
checked.
Also improve tree traversal when counting the number of signs.
Instead of looping over the to be checked range and counting
the overlap for each row, keep track of the overlap in an
array and add this to the count.
Problem:
Since e057b38e70#20757 we support empty key in JSON encode/decode,
but we don't allow it in RPC object => Vim dict conversion. But empty
string is a valid key in Vim dicts and the msgpack spec.
Empty string key was disallowed in 7c01d5ff92 (2014) but that
commit/PR doesn't explicitly discuss it, so presumably it was a "seems
reasonable" decision (or Vimscript didn't allow empty keys until later).
Solution:
Remove the check in `object_to_vim()`. Note that
`tv_dict_item_alloc_len` will invoke `memcpy(…, 0)` but that's allowed
by the C spec: https://stackoverflow.com/a/3751937/152142
Currently, the value of $COLORTERM in :terminal in tests depends on
outer environment because of 'notermguicolors'.
If $COLORTERM is not set in :terminal, an inner Nvim instance will try
to detect 'termguicolors' support, which may interfere with tests.
So set 'termguicolors' in outer Nvim instance unless $COLORTERM needs to
be overridden, and unset it in inner Nvim instance when running TUI.
16 bytes is not enough room for existing usage of the buffer by the
tests, so the name may get truncated and cause log_spec test to fail:
FAILED test/functional/core/log_spec.lua @ 30: log messages are formatted with name or test id
test/helpers.lua:146: retry() attempts: 51
test/helpers.lua:155: Pattern "%.%d+%.%d/c +server_init:%d+: test log message" not found in log (last 100 lines): Xtest_logging:
ERR 2023-11-24T23:36:34.252 T1274.2445945.0 server_init:57: test log message
ERR 2023-11-24T23:36:34.275 T1274.2445945.0 server_init:57: test log message
Set 'notermguicolors' in tests which spawn a child Nvim process to force
existing tests to use 16 colors. Also refactor the child process
invocation to make things a little bit less messy.
If the color scheme is changed in a startup script, nvim used to send
multiple default_colors_set events, one for the default color scheme
and one for the user's chosen color scheme. This would cause flicker in
some UI:s. Throttle this event until we actually start drawing on the
screen.
fixes#26372
Followup to 27501d3b6a.
Problem:
CI sometimes fails. Something is triggering an extra fsync().
FAILED test/functional/core/fileio_spec.lua @ 52: fileio fsync() with 'nofsync' #8304
test/functional/core/fileio_spec.lua💯 Expected objects to be the same.
Passed in:
(number) 5
Expected:
(number) 4
Solution:
Relax the assertion.
Enable 'termguicolors' automatically when Nvim can detect that truecolor
is supported by the host terminal.
If $COLORTERM is set to "truecolor" or "24bit", or the terminal's
terminfo entry contains capabilities for Tc, RGB, or setrgbf and
setrgbb, then we assume that the terminal supports truecolor. Otherwise,
the terminal is queried (using both XTGETTCAP and SGR + DECRQSS). If the
terminal's response to these queries (if any) indicates that it supports
truecolor, then 'termguicolors' is enabled.
Problem:
Empty string is a valid JSON key, but json_decode() treats an object
with empty key as ":help msgpack-special-dict". #20757
:echo json_decode('{"": "1"}')
{'_TYPE': [], '_VAL': [['', '1']]}
Note: vim returns `{'': '1'}`.
Solution:
Allow empty string as an object key.
Note that we still (currently) disallow empty keys in object_to_vim() (since 7c01d5ff92):
f64e4b43e1/src/nvim/api/private/converter.c (L333-L334)Fix#20757
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
Problem:
The test for 'nofsync' swapfile preservation on a deadly signal, does
not actually assert anything.
followup to 1fd29a2884
Solution:
Check that swapfile contents are present after getting SIGTERM.
TODO: this doesn't really verify that 'fsync' was called; it still
passes with this patch:
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 216e39f3e81c..7a635520401d 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -838,7 +838,7 @@ void preserve_exit(const char *errmsg)
if (errmsg != NULL) {
os_errmsg("Vim: preserving files...\r\n");
}
- ml_sync_all(false, false, true); // preserve all swap files
+ ml_sync_all(false, false, false); // preserve all swap files
break;
}
}
However it correctly fails with this patch, at least:
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 216e39f3e81c..f2306c310ddc 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -838,7 +838,6 @@ void preserve_exit(const char *errmsg)
if (errmsg != NULL) {
os_errmsg("Vim: preserving files...\r\n");
}
- ml_sync_all(false, false, true); // preserve all swap files
break;
}
}
Problem:
When `vim._foldupdate()` is invoked inside a scheduled callback, the
cursor may have moved to a line with a closed fold, e.g., after `dd` on
the line that is one line above a folded region. Then it opens the fold,
which is unnecessary and distracting. Legacy foldexprs do not have this
issue.
Solution:
Don't explicitly open folds on cursor.
Note:
This doesn't completely prevent spurious opening of folds. That is due
to bugs in treesitter foldexpr algorithm, which should be addressed
separately.
Problem: Confusing error for missing key.
Solution: Use the actualy key for the error. (closesvim/vim#9241)
5c1ec439f0
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: Set_ref_in_list() only sets ref in items.
Solution: Rename to set_ref_in_list_items() to avoid confusion.
7be3ab2589
Omit set_ref_in_list() and set_ref_in_dict(): only used in popup window,
if_pyth and if_lua.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Problem: 'breakindent' is not drawn after diff filler lines.
Solution: Correct check for whether 'breakindent' should be drawn.
closes: vim/vim#13624588f20dece
Cherry-pick Test_diff_with_syntax() change from patch 9.0.1257.
runtime(doc): remove non-existent parameter in shift-command (vim/vim#13626)
The variant with the {count} parameter is explained in the next item.
2103a56eab
N/A patches:
vim-patch:9.0.2150: Using int for errbuflen in option funcs
vim-patch:3f7855a6123c
Co-authored-by: Roy Orbitson <Roy-Orbison@users.noreply.github.com>
Problem:
CI sometimes fails. Something is triggering an extra fsync().
FAILED test/functional/core/fileio_spec.lua @ 52: fileio fsync() codepaths #8304
test/functional/core/fileio_spec.lua:87: Expected objects to be the same.
Passed in:
(number) 3
Expected:
(number) 2
stack traceback:
test/functional/core/fileio_spec.lua:87: in function <test/functional/core/fileio_spec.lua:52>
Solution:
Relax the assertion to `fsync >= 2` instead of exactly 2.
(Note this is not a behavior change: the next assertion has always
checked `fsync == 4`, it's just that the intermediate 3rd fsync was
never explicitly asserted.)
Problem: Vim does not detect pacman.log file
Solution: Detect pacmanlogs and add syntax highlighting
pacman.log is a filetype common to Arch Liux and related distributions.
Add some simple syntax highlighting for the pacmanlog filetype.
closes: vim/vim#136181e5d66408e
Co-authored-by: Ronan Pigott <ronan@rjp.ie>
Problem:
With vim.treesitter.foldexpr, `o`-ing two lines above a folded region
opens the fold. This does not happen with legacy foldexprs. For example,
make a markdown file with the following text (without indentation),
enable treesitter fold, and follow the instruction in the text.
put cursor on this line and type zoo<Esc>
initially folded, revealed by zo
# then this fold will be opened
initially folded, revealed by o<Esc>
Analysis:
* `o` updates folds first (done in `changed_lines`), evaluating
foldexpr, and then invokes `on_bytes` (done in `extmark_splice`).
* Treesitter fold allocates the foldinfo for added lines (`add_range`)
on `on_bytes`.
* Therefore, when treesitter foldexpr is invoked while running `o`, it
sees outdated foldinfo.
Solution:
`extmark_splice`, and then `changed_lines`. This seems to be the
standard order in other places, e.g., `nvim_buf_set_lines`.
Problem:
Not all Lua code is checked by stylua. Automating code-style is an
important mechanism for reducing time spent on accidental
(non-essential) complexity.
Solution:
- Enable lintlua for `test/unit/` directory.
- TODO: only `test/functional/` remains unchecked.
previous: 45fe4d11ad
previous: 517f0cc634