| Age | Commit message (Collapse) | Author | Files |
|
Problem: using int as bool
Solution: refactor: use bool type for internal flags in buf_T
(Hirohito Higashi)
Change the type of 23 internal state flag fields in buf_T from int
to bool for improved type clarity and code readability.
These fields are pure boolean flags that are never accessed via the
option system's varp (which uses *(int *)varp = value), never compared
with int fields holding non-0/1 values, and never use tristate values.
Converted fields:
- State flags: b_dev_valid, b_saving, b_mod_set, b_new_change,
b_marks_read, b_modified_was_set, b_did_filetype, b_keep_filetype,
b_au_did_filetype, b_u_synced, b_scanned, b_p_initialized
- Characteristic flags: b_has_textprop, b_may_swap, b_did_warn,
b_help, b_spell, b_shortname, b_has_sign_column, b_netbeans_file,
b_was_netbeans_file, b_write_to_channel, b_diff_failed
All TRUE/FALSE assignments to these fields have been updated to
true/false accordingly. The type of temporary save variables
(e.g. help_save in tag.c) has also been adjusted to bool.
Option value fields (b_p_XXX) are kept as int because they are
accessed via the option system and some use tristate (-1) semantics.
Fields compared with int option values (b_start_eof, b_start_eol,
b_start_bomb) are also kept as int to preserve comparison integrity.
closes: vim/vim#20020
https://github.com/vim/vim/commit/1966a1c8963f59c00a9f25d129bec90366205e1b
Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
|
- `src/nvim/ex_cmds_defs.h`: use "U" instead of "u" per
`readability-uppercase-literal-suffix`
|
|
Problem: Undefined behavior when 'undodir' contains empty entry.
Solution: Don't try to remove trailing slashes from empty path. Also
don't remove a colon on Windows while at it.
|
|
Fixes the following Coverity warning:
*** CID 549779: Integer handling issues (INTEGER_OVERFLOW)
/src/nvim/undo.c: 717 in u_get_undo_file_name()
711 dir_name[dir_len] = NUL;
712
713 // Remove trailing pathseps from directory name
714 char *p = &dir_name[dir_len - 1];
715 while (vim_ispathsep(*p)) {
716 *p-- = NUL;
>>> CID 549779: Integer handling issues (INTEGER_OVERFLOW)
>>> Expression "dir_len--", where "dir_len" is known to be equal to 0, underflows the type of "dir_len--", which is type "size_t".
717 dir_len--;
718 }
719
720 bool has_directory = os_isdir(dir_name);
721 if (!has_directory && *dirp == NUL && !reading) {
722 // Last directory in the list does not exist, create it.
|
|
Problem: too many strlen() calls
Solution: refactor concat_fname() and remove calls to strlen()
(John Marriott)
Function `concat_fnames()` can make up to 5 calls to `STRLEN()` (either
directly or indirectly via `STRCAT()`). In many cases the lengths of
arguments `fname1` and/or `fname2` are either known or can simply be
calculated.
This Commit refactors this function to accept the lengths of arguments
`fname1` and `fname2` as arguments. It also adds new argument `ret` to
return the resulting string as a `string_T`.
Additionally:
- function `add_pack_dir_to_rtp()` in `scriptfile.c`:
Use a `string_T` to store local variables `new_rtp` and `afterdir`.
Replace calls to `STRCAT()` with calls to `STRCPY()`.
Change type of variable `keep` to `size_t` for consistency with
other lengths.
- function `qf_get_fnum()` in `quickfix.c`:
Use a `string_T` to store local variables `ptr` and `bufname`
- function `qf_push_dir()` in `quickfix.c`:
Use a `string_T` to store local variable `dirname`.
Replace call to `vim_strsave()` with `vim_strnsave()`.
- function `qf_guess_filepath()` in `quickfix.c`:
Use a `string_T` to store local variable `fullname`.
- function `make_percent_swname()` in `memline.c`:
Rename some variables to better reflect their use.
Use a `string_T` to store local variables `d` and `fixed_name`.
Slightly refactor to remove need to create an extra string.
- function `get_file_in_dir()` in `memline.c`:
Use a `string_T` to store local variables `tail` and `retval`.
Move some variables closer to where they are used.
- function `cs_resolve_file()` in `if_cscope.c`:
Use a `string_T` to store local variable `csdir`.
Remove one call to `STRLEN()`.
- function `add_pathsep()` in `filepath.c`:
Refactor and remove 1 call to `STRLEN()`
- function `set_init_xdg_rtp()` in `option.c`:
Use a `string_T` to store local variable `vimrc_xdg`.
closes: vim/vim#19854
https://github.com/vim/vim/commit/cb51add7ae400a47407fb7fb7b7a54e238d4fdf4
Co-authored-by: John Marriott <basilisk@internode.on.net>
Co-authored-by: Christian Brabandt <cb@256bit.org>
|
|
Problem:
In aec3d7915c55fc0b7dc73f6186cf0ae45d416d33 Vim changed prompt-buffers
to respect 'modified' so the termdebug plugin can "control closing the
window". But for most use-cases (REPL, shell, AI "chat", …),
prompt-buffers are in practice always "modified", and no way to "save"
them, so *implicitly* setting 'modified' is noisy and annoying.
Solution:
Don't implicitly set 'modified' when a prompt-buffer is updated.
Plugins/users can still explicitly set 'modified', which will then
trigger the "E37: No write since last change" warning.
|
|
Problem: u_savecommon with reload = true wrongly uses curbuf.
Solution: use buf. Fix comments.
|
|
Problem: Newlines intended to write messages below the cmdline or to
mark the start of a new message on message grid are emitted
through ext_messages. This results in unnecessary newlines for
a UI that has decoupled its message area from the cmdline.
msg_col is set directly in some places which is not transmitted
to msg_show events.
Various missing message kind for list commands.
Trailing newlines on various list commands.
Solution: Only emit such newlines without ext_messages enabled.
Use msg_advance() instead of setting msg_col directly.
Assign them the "list_cmd" kind.
Ensure no trailing newline is printed.
|
|
Problem: undo: cursor position not correctly restored
Solution: Do not override the saved cursor position (altermo)
closes: vim/vim#19052
https://github.com/vim/vim/commit/a722da29c128576d581f451f3f6282de27680d9f
Co-authored-by: altermo <107814000+altermo@users.noreply.github.com>
|
|
Problem: 'fsync' option cannot be set per buffer
Solution: Make 'fsync' option global-local
(glepnir)
closes: vim/vim#19019
https://github.com/vim/vim/commit/4d5b30372663e8ea356b25fe94334558c6ae283f
Co-authored-by: glepnir <glephunter@gmail.com>
|
|
Problem:
:messages history include the "search hit BOTTOM, continuing at TOP" message,
which is noise.
Solution:
Set msg_hist_off before giving the warning and reset it after warning.
|
|
Problem: Text properties crossing lines not handled correctly.
Solution: When saving for undo include an extra line when needed and do not
adjust properties when undoing. (Axel Forsman, closes vim/vim#5875)
ML_DEL_UNDO, ML_APPEND_UNDO are no-opt because textprop feature is N/A.
https://github.com/vim/vim/commit/a9d4b84d97fb74061eeb42c1433e111fb58825dc
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
|
Problem: An empty change is reported to a listener.
Solution: Do not report an empty change. (closes vim/vim#9768) Remove unused
return value.
https://github.com/vim/vim/commit/55737c2a31ed450dd7bf2a9c587adfbb32b755bb
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
|
Problem: Too many #ifdefs.
Solution: Graduate the jumplist feature.
https://github.com/vim/vim/commit/739f13a55b4982efb37ebc9282e7f79975fff982
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
|
Problem: Error for invalid range when using listener and undo. (Paul Jolly)
Solution: Do not change the cursor before the lines are restored.
(closes vim/vim#4908)
https://github.com/vim/vim/commit/4544bd2f247425c9dd743c76618dd70f53c72538
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
|
These are not needed after #35129 but making uncrustify still play nice
with them was a bit tricky.
Unfortunately `uncrustify --update-config-with-doc` breaks strings
with backslashes. This issue has been reported upstream,
and in the meanwhile auto-update on every single run has been disabled.
|
|
Problem: Functions used in one file are global.
Solution: Add "static". (Yegappan Lakshmanan, closes vim/vim#4840)
https://github.com/vim/vim/commit/5843f5f37b0632e2d706abc9014bfd7d98f7b02e
Co-authored-by: Bram Moolenaar <Bram@vim.org>
|
|
Result of `make iwyu` (after some "fixups").
|
|
- Typo/bug in msg_outtrans_long passing string length as "hist" argument.
- Avoid truncating message in msg_outtrans_long with ext_messages (followup to
1097d239c307a10a87fa995c4cfbe5987939e177).
- Remove `_hl` from `msg_keep`, `smsg_keep` as there is no non-`_hl` variant.
- `msg_printf_hl` is removed (identical to `smsg` except it sets
`msg_scroll = true`, seemingly as a caveat to force a more prompt in
cmdline mode). Move this logic to the only the only place this was
used in ex_getln.c.
|
|
Problem: cannot handle `:undo` and `:redo` messages in a special way,
e.g. replace one by another.
Solution: add `undo` kind.
|
|
Problem: Option metadata like list of valid values for an option and
option flags are not listed in the `options.lua` file and are instead
manually defined in C, which means option metadata is split between
several places.
Solution: Put metadata such as list of valid values for an option and
option flags in `options.lua`, and autogenerate the corresponding C
variables and enums.
Supersedes #28659
Co-authored-by: glepnir <glephunter@gmail.com>
|
|
This makes it possible to use HLF_ values directly as highlight id:s
and avoids +1 adjustments especially around messages.
|
|
Problem: Highlight group id is not propagated to the end of the message call
stack, where ext_messages are emitted.
Solution: Refactor message functions to pass along highlight group id
instead of attr id.
|
|
This also makes shada reading slightly faster due to avoiding
some copying and allocation.
Use keysets to drive decoding of msgpack maps for shada entries.
|
|
Problem:
Variables are often assigned multiple places in common patterns.
Solution:
Replace these common patterns with different patterns that reduce the
number of assignments.
Use `MAX` and `MIN`:
```c
if (x < y) {
x = y;
}
// -->
x = MAX(x, y);
```
```c
if (x > y) {
x = y;
}
// -->
x = MIN(x, y);
```
Use ternary:
```c
int a;
if (cond) {
a = b;
} els {
a = c;
}
// -->
int a = cond ? b : c;
```
|
|
|
|
A lot of functions in move.c only worked for curwin, alternatively
took a `wp` arg but still only work if that happens to be curwin.
Refactor those that are needed for update_topline(wp) to work
for any window.
fixes #27723
fixes #27720
|
|
Problem: duplicate code when cleaning undo stack
Solution: refactor undo cleanup into a single public function
related: vim/vim#13928
https://github.com/vim/vim/commit/9071ed8107244e0c56a16b77d1c28e975cb21dd2
Co-authored-by: Christian Brabandt <cb@256bit.org>
|
|
Problem:
Virtual text not redrawn properly after undo moves its extmark.
Solution:
Redraw the moved extmark's pre-undo position.
|
|
Problem: Marks moved by undo may be lost to "b_signcols.count".
Solution: Count signs for each undo object separately instead of
once for the entire undo.
|
|
|
|
This expands on the global "don't pay for what you don't use" rules for
these special extmark decorations:
- inline virtual text, which needs to be processed in plines.c when we
calculate the size of text on screen
- virtual lines, which are needed when calculating "filler" lines
- signs, with text and/or highlights, both of which needs to be
processed for the entire line already at the beginning of a line.
This adds a count to each node of the marktree, for how many special
marks of each kind can be found in the subtree for this node. This makes
it possible to quickly skip over these extra checks, when working in
regions of the buffer not containing these kind of marks, instead of
before where this could just be skipped if the entire _buffer_
didn't contain such marks.
|
|
|
|
Problem: Some edge cases to the old (pre-#26406) and current "b_signcols"
structure result in an incorrectly sized "auto" 'signcolumn'.
Solution: * Implement a simpler 'signcolumn' validation strategy by immediately
counting the number of signs in a range upon sign insertion and
deletion. Decrease in performance here but there is a clear path
forward to decreasing this performance hit by moving signs to a
dedicated marktree, or by adding meta-data to the existing
marktree which may be queried more efficiently?
* Also replace "max_count" and keep track of the number of lines with
a certain number of signs. This makes it so that it is no longer
necessary to scan the entire buffer when the maximum number of signs
decreases. This likely makes the commit a net increase in performance.
* To ensure correctness we also have re-initialize the count for an
edited region that spans multiple lines. Such an edit may move the
signs within it. Thus we count and decrement before splicing the
marktree and count and increment after.
|
|
Remove `export` pramgas from defs headers as it causes IWYU to believe
that the definitions from the defs headers comes from main header, which
is not what we really want.
|
|
|
|
Reference: https://github.com/neovim/neovim/issues/6371.
|
|
Specifically, specify that each initialization should be done on a
separate line.
|
|
See also: https://github.com/neovim/neovim/pull/26364
|
|
FUNC_ATTR_* should only be used in .c files with generated headers.
Defining FUNC_ATTR_* as empty in headers causes misuses of them to be
silently ignored. Instead don't define them by default, and only define
them as empty after a .c file has included its generated header.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This requires removing the "Inner expression should be aligned" rule
from clint as it prevents essentially any formatting regarding ternary
operators.
|
|
- reduce variable scope
- prefer initialization over declaration and assignment
|
|
This was removed from Vim in patch 8.1.0681.
|