Age | Commit message (Collapse) | Author |
|
Problem: More code can use ml_get_buf_len() instead of STRLEN().
Solution: Change more STRLEN() calls to ml_get_buf_len(). Also do not
set ml_line_textlen in ml_replace_len() if "has_props" is set,
because "len_arg" also includes the size of text properties in
that case. (zeertzjq)
closes: #14183
Signed-off-by: zeertzjq <zeertzjq@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
|
|
Problem: Cannot keep a buffer focused in a window
(Amit Levy)
Solution: Add the 'winfixbuf' window-local option
(Colin Kennedy)
fixes: #6445
closes: #13903
Signed-off-by: Colin Kennedy <colinvfx@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
|
|
Problem: [security]: autocmd cause use-after-free in set_curbuf()
(kawarimidoll)
Solution: check side-effect of BufLeave autocommand, when the number
of windows changed, close windows containing buffers that will
be wiped, if curbuf changed unexpectedly make sure b_nwindows
is decremented otherwise it cannot be wiped
set_curbuf() already makes some efforts to ensure the BufLeave
autocommands do not cause issues. However there are still 2 issues
that are not taken care of:
1) If a BufLeave autocommand opens a new window containing the same
buffer as that is going got be closed in close_buffer() a bit later,
we suddenly have another window open, containing a free'd buffer. So we
must check if the number of windows changed and if it does (and the
current buffer is going to be wiped (according to the 'bufhidden'
setting), let's immediately close all windows containing the current
buffer using close_windows()
2) If a BufLeave autocommand changes our current buffer (displays it in
the current window), buf->b_nwindow will be incremented. As part of
set_curbuf() we will however enter another buffer soon, which means, the
newly created curbuf will have b_nwindows still have set, even so the
buffer is no longer displayed in a window. This causes later problems,
because it will no longer be possible to wipe such a buffer. So just
before entering the final buffer, check if the curbuf changed when
calling the BufLeave autocommand and if it does (and curbuf is still
valid), decrement curbuf->b_nwindows.
Both issues can be verified using the provided test (however the second
issue only because such an impacted buffer won't be wiped, causing
futher issues in later tests).
fixes: #13839
closes: #14104
Signed-off-by: Christian Brabandt <cb@256bit.org>
|
|
Problem: buffer-completion code too complicated and does not always
find all matches (irisjae)
Solution: do not try to anchor pattern to beginning of line or
directory-separator, always return all matches
Note: we are considering the non-fuzzy buffer-matching here.
Currently, the buffer-completion code makes 2 attempts to match a
pattern against the list of available patterns. First try is to match
the pattern and anchor it to either the beginning of the file name or
at a directory-separator (// or \\).
When a match is found, Vim returns the matching buffers and does not try
to find a match anywhere within a buffer name. So if you have opened two
buffers like /tmp/Foobar.c and /tmp/MyFoobar.c using `:b Foo` will only
complete to the first filename, but not the second (the same happens
with `getcompletion('Foo', 'buffer')`).
It may make sense, that completion priorities buffer names at directory
boundaries, but it inconsistent, may cause confusion why a certain
buffer name is not completed when typing `:b Foo<C-D>` which returns
only a single file name and then pressing Enter (to switch to that
buffer), Vim will error with 'E93: More than one match for Foo').
Similar things may happen when wiping the /tmp/Foobar.c pattern and
afterwards the completion starts completing other buffers.
So let's simplify the code and always match the pattern anywhere in the
buffer name, do not try to favor matches at directory boundaries. This
is also simplifies the code a bit, we do not need to run over the list
of buffers several times, but only twice.
fixes #13894
closes: #14082
Signed-off-by: Christian Brabandt <cb@256bit.org>
|
|
Problem: duplicate code when cleaning undo stack
Solution: refactor undo cleanup into a single public function
related: #13928
Signed-off-by: Christian Brabandt <cb@256bit.org>
|
|
Problem: E95 is possible if a buffer called "[Command Line]" already
exists when opening the cmdwin. This can also happen if the
cmdwin's buffer could not be deleted when closing.
Solution: Un-name the cmdwin buffer, and give it a special name instead,
similar to what's done for quickfix buffers and for unnamed
prompt and scratch buffers. As a result, BufFilePre/Post are
no longer fired when opening the cmdwin. Add a "command" key
to the dictionary returned by getbufinfo() to differentiate
the cmdwin buffer instead. (Sean Dewar)
NOTE: This is technically a breaking change... maybe this needs a different
solution? (Or maybe this issue can be ignored...)
A GitHub search reveals some plugins expect the old behaviour. However, many of
those plugins also do not seem to account for the string being translated, so
they are subtly broken anyway (not withstanding the fact that you can call any
old buffer "[Command Line]" too...)
closes: #12819
Signed-off-by: Sean Dewar <seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
|
|
Problem: is*() and to*() function may be unsafe
Solution: Add SAFE_* macros and start using those instead
(Keith Thompson)
Use SAFE_() macros for is*() and to*() functions
The standard is*() and to*() functions declared in <ctype.h> have
undefined behavior for negative arguments other than EOF. If plain char
is signed, passing an unchecked value from argv for from user input
to one of these functions has undefined behavior.
Solution: Add SAFE_*() macros that cast the argument to unsigned char.
Most implementations behave sanely for negative arguments, and most
character values in practice are non-negative, but it's still best
to avoid undefined behavior.
The change from #13347 has been omitted, as this has already been
separately fixed in commit ac709e2fc0db6d31abb7da96f743c40956b60c3a
(v9.0.2054)
fixes: #13332
closes: #13347
Signed-off-by: Keith Thompson <Keith.S.Thompson@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
|
|
Problem: [security] use-after-free from buf_contents_changed()
Solution: block autocommands
Signed-off-by: Christian Brabandt <cb@256bit.org>
|
|
Problem: heap-use-after-free in bt_normal()
Solution: check that buffer is still valid
Signed-off-by: Christian Brabandt <cb@256bit.org>
|
|
Problem: Tabline highlight wrong after truncated double width label.
Solution: Fill up half a double width character later. (closes #12614)
|
|
Problem: Get E304 when using 'cryptmethod' "xchacha20v2". (Steve Mynott)
Solution: Add 4th crypt method to block zero ID check. Avoid syncing a swap
file before reading the file. (closes #12433)
|
|
Problem: "file N of M" message is not translated.
Solution: Make argument count message translatable. (close #12429)
|
|
Problem: RedrawingDisabled not used consistently.
Solution: Avoid RedrawingDisabled going negative. Set RedrawingDisabled in
win_split_ins(). (closes #11961)
|
|
Problem: Code for handling 'switchbuf' is repeated.
Solution: Add a function to handle 'switchbuf'. (Yegappan Lakshmanan,
closes #12397)
|
|
Problem: Some commands for opening a file don't use 'switchbuf'.
Solution: Use 'switchbuf' for more commands. (Yegappan Lakshmanan,
closes #12383, closes #12381)
|
|
Problem: The ruler percentage can't be localized.
Solution: Use a string that can be translated. (Emir Sari, closes #12311)
|
|
Problem: Decrypting with libsodium may fail if the library changes.
Solution: Add parameters used to the encrypted file header. (Christian
Brabandt, closes #12279)
|
|
Problem: Code indenting is confused by macros.
Solution: Put semicolon after the macros instead of inside. (Ozaki Kiichi,
closes #12257)
|
|
Problem: "clear" macros are not always used.
Solution: Use ALLOC_ONE, VIM_CLEAR, CLEAR_POINTER and CLEAR_FIELD in more
places. (Yegappan Lakshmanan, closes #12104)
|
|
Problem: Illegal memory access when using :ball in Visual mode.
Solution: Stop Visual mode when using :ball. (Pavel Mayorov, closes #11923)
|
|
Problem: Handling new value of an option has a long "else if" chain.
Solution: Use a function pointer. (Yegappan Lakshmanan, closes #12015)
|
|
Problem: Scrolling two lines with even line count and 'scrolloff' set.
Solution: Adjust how the topline is computed. (closes #10545)
|
|
Problem: 'statusline' only supports one "%=" item.
Solution: Add support for multiple "%=" items. (TJ DeVries, Yegappan
Lakshmanan, closes #11970, closes #11965)
|
|
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11792)
|
|
Problem: Invalid memory access with bad 'statusline' value.
Solution: Avoid going over the NUL at the end.
|
|
Problem: Code is indented more than needed.
Solution: Use an early return to reduce indentation. (Yegappan Lakshmanan,
closes #11769)
|
|
Problem: Cannot display 'showcmd' somewhere else.
Solution: Add the 'showcmdloc' option. (Luuk van Baal, closes #11684)
|
|
Problem: Using one window for executing autocommands is insufficient.
Solution: Use up to five windows for executing autocommands.
|
|
Problem: Crash when unletting a variable while listing variables.
Solution: Disallow changing a hashtable while going over the entries.
(closes #11435)
|
|
Problem: Handling 'statusline' errors is spread out.
Solution: Pass the option name to the lower levels so the option can be
reset there when an error is encountered. (Luuk van Baal,
closes #11467)
|
|
|
|
Problem: Dummy buffer ends up in a window.
Solution: Disallow navigating to a dummy buffer.
|
|
Problem: Cannot use 'indentexpr' for Lisp indenting.
Solution: Add the 'lispoptions' option.
|
|
Problem: Too many #ifdefs.
Solution: Gradudate the +cmdline_info feature. (Martin Tournoij,
closes #11330)
|
|
Problem: Quitting/unloading/hiding a terminal buffer does not always work
properly.
Solution: Avoid that ":q!" leaves an empty buffer behind. ":bunload!" also
kills the job and unloads the buffer. ":hide" does not unload the
buffer. (Yee Cheng Chin, closes #11323)
|
|
Problem: :confirm does not work properly for a terminal buffer.
Solution: Handle :confirm for a terminal buffer differently. (Yee Cheng
Chin, closes #11312)
|
|
Problem: Evaluating "expr" options has more overhead than needed.
Solution: Use call_simple_func() for 'foldtext', 'includeexpr', 'printexpr',
"expr" of 'spellsuggest', 'diffexpr', 'patchexpr', 'balloonexpr',
'formatexpr', 'indentexpr' and 'charconvert'.
|
|
Problem: SpellFileMissing autocmd may delete buffer.
Solution: Disallow deleting the current buffer to avoid using freed memory.
|
|
Problem: Netrw plugin does not show remote files.
Solution: Do read a file when 'buftype' is "acwrite". (closes #10983)
|
|
Problem: BufReadCmd not triggered when loading a "nofile" buffer. (Maxim
Kim)
Solution: Call readfile() but bail out before reading a file.
(closes #10983)
|
|
Problem: Compiler warning for unused argument.
Solution: Add UNUSED.
|
|
Problem: No good reason why the "gf" command is not in the tiny version.
Solution: Graduate the file_in_path feature.
|
|
Problem: Too many #ifdefs.
Solution: Make some functions always available.
|
|
Problem: Build failure without the +quickfix feature.
Solution: Add #ifdef.
|
|
Problem: bufload() reads a file even if the name is not a file name. (Cyker
Way)
Solution: Do not read the file when the buffer name is not a file name.
(closes #10975)
|
|
Problem: Mechanism to prevent recursive screen updating is incomplete.
Solution: Add "redraw_not_allowed" and set it in build_stl_str_hl().
(issue #10952)
|
|
Problem: No good reason why text objects are only in larger builds.
Solution: Graduate +textobjects.
|
|
Problem: Redraw flags are not named specifically.
Solution: Prefix "UPD_" to the flags, for UPDate_screen().
|
|
Problem: ml_get error when switching buffer in Visual mode.
Solution: End Visual mode when switching buffer. (closes #10902)
|
|
Problem: Conditions are always true.
Solution: Remove useless conditions. (closes #10802)
|