This adds the checks in https://neovim.io/doc/reports/clang/ when using
clang-tidy. The strategy is to enable all clang-analyzer checks, and
disable only the checks for the warnings that exist currently. This
allows us to eliminate each warning type without blocking ongoing work,
but also without adding bugs for already eliminated warnings.
The plan is to eventually eliminate https://neovim.io/doc/reports/clang/
by completely integrating it into the clang-tidy check.
Also add make and cmake targets `clang-analyzer` to run this check.
*** CID 466056: Control flow issues (DEADCODE)
/src/nvim/window.c: 6951 in file_name_in_line()
6945 // Search backward for first char of the file name.
6946 // Go one char back to ":" before "//", or to the drive letter before ":\" (even if ":"
6947 // is not in 'isfname').
6948 while (ptr > line) {
6949 if ((len = (size_t)(utf_head_off(line, ptr - 1))) > 0) {
6950 ptr -= len + 1;
>>> CID 466056: Control flow issues (DEADCODE)
>>> Execution cannot reach the expression "path_has_drive_letter(ptr - 2)" inside this statement: "if (vim_isfilec((uint8_t)pt...".
6951 } else if (vim_isfilec((uint8_t)ptr[-1])
6952 || (len >= 2 && path_has_drive_letter(ptr - 2))
6953 || ((options & FNAME_HYP) && path_is_url(ptr - 1))) {
6954 ptr--;
6955 } else {
6956 break;
"VimEnter foo" was accepted as a valid event name for "VimEnter".
Events delimited with commas, eg. "VimEnter,BufRead", were also
accepted, even though only the first event was actually parsed.
Co-authored-by: ii14 <ii14@users.noreply.github.com>
long is 32 bits on windows, while it is 64 bits on other architectures.
This makes the type suboptimal for a codebase meant to be
cross-platform. Replace it with more appropriate integer types.
runtime: make command name for &iskeywordprg more unique (vim/vim#13297)
See https://github.com/vim/vim/pull/13213/commits by @dkearns:
Rename 'keywordprg' user command to ShKeywordPrg as this is just a
leaking implementation detail.
1e33cd72b6
Co-authored-by: Enno <Konfekt@users.noreply.github.com>
The 'arabicshape' feature of vim is a transformation of unicode text to
make arabic and some related scripts look better at display time. In
particular the content of a cell will be adjusted depending on the
(original) content of the cells just before and after it.
This is implemented by the arabic_shape() function in nvim. Before this
commit, shaping was invoked in four different contexts:
- when rendering buffer text in win_line()
- in line_putchar() for rendering virtual text
- as part of grid_line_puts, used by messages and statuslines and
similar
- as part of draw_cmdline() for drawing the cmdline
This replaces all these with a post-processing step in grid_put_linebuf(),
which has become the entry point for all text rendering after recent
refactors.
An aim of this is to make the handling of multibyte text yet simpler.
One of the main reasons multibyte chars needs to be "parsed" into
codepoint arrays of composing chars is so that these could be inspected
for the purpose of shaping. This can likely be vastly simplified in many
contexts where only the total length (in bytes) and width of composed
char is needed.
Problem: The style guide currently recommends having a `default:` case for switch statements that are not conditional on an enumerated value. Additionally, it recommends using `assert(false)` if `default:` is unreachable. This is problematic because `assert()` only runs on debug builds, which may lead to confusing breakages in release builds. Moreover, this suggestion is followed nowhere in the C code and `abort()` is used everywhere instead.
Solution: Suggest using `abort()` instead of `assert(false)`, that way the program always terminates if a logically unreachable case is reached.
runtime(sh): Update ftplugin (vim/vim#13213)
Rename 'keywordprg' user command to ShKeywordPrg as this is just a
leaking implementation detail.
2a281ccca0
Co-authored-by: dkearns <dougkearns@gmail.com>
Problem: strange error number
Solution: change error number,
add doc tag for E1507
closes: vim/vim#13270ea746f9e86
Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
Problem:
On Windows, "gf" fails on a filepath that has a line:column suffix.
Example:
E447: Can't find file "src/app/core/services/identity/identity.service.ts:64:23"
Solution:
- Remove ":" from 'isfname' on Windows. Colon is not a valid filename
character (except for the drive-letter).
- Handle drive letters specially in file_name_in_line().
Fixes#25160
runtime(netrw): diff (`df`) may open the wrong window (vim/vim#13275)
closes: vim/vim#113590e95841004
Co-authored-by: KSR-Yasuda <31273423+KSR-Yasuda@users.noreply.github.com>
This finalizes the long running refactor from the old TUI-focused grid
implementation where text-drawing cursor was not separated from the
visible cursor.
Still, the pattern of setting cursor position together with updating a
line was convenient. Introduce grid_line_cursor_goto() to still allow
this but now being explicit about it.
Only having batched drawing functions makes code involving drawing
a bit longer. But it is better to be explicit, and this highlights
cases where multiple small redraws can be grouped together. This was the
case for most of the changed places (messages, lastline, and :intro)
> The application shall ensure that the function returns an integer less
than, equal to, or greater than 0, if the first argument is considered
respectively less than, equal to, or greater than the second. If two
members compare as equal, their order in the sorted array is unspecified.
https://pubs.opengroup.org/onlinepubs/009696899/functions/qsort.html
Problem: Scrolling non-current window using mouse is inconsistent
depending on 'scrollbind'/'scrolloff' and different from GUI
vertical scrollbar when 'cursorbind' is set.
Solution: Don't move cursor in non-current windows for 'cursorbind' if
cursor in the current window didn't move.
closes: vim/vim#13219closes: vim/vim#132108e5f26ec6a
Problem: Cannot scroll up in diff mode with many filler lines and zero
'scrolloff'.
Solution: Invalidate w_cline_row before calling comp_botline().
closes: vim/vim#132560583491277
Problem:
The swapfile "E325: ATTENTION" dialog is displayed when editing a file
already open in another (running) Nvim. Usually this behavior is
annoying and irrelevant:
- "Recover" and the other options ("Open readonly", "Quit", "Abort") are
almost never wanted.
- swapfiles are less relevant for "multi-Nvim" since 'autoread' is
enabled by default.
- Even less relevant if user enables 'autowrite'.
Solution:
Define a default SwapExists handler which does the following:
1. If the swapfile is owned by a running Nvim process, automatically
chooses "(E)dit anyway" (caveat: this creates a new, extra swapfile,
which is mostly harmless and ignored except by `:recover` or `nvim -r`.
2. Shows a 1-line "ignoring swapfile..." message.
3. Users can disable the default SwapExists handler via `autocmd! nvim_swapfile`.
long is 32 bits on windows, while it is 64 bits on other architectures.
This makes the type suboptimal for a codebase meant to be
cross-platform. Replace it with more appropriate integer types.
msg_puts_display was more complex than necessary in nvim, as in
nvim, it no longer talks directly with a terminal.
In particular we don't need to scroll the grid before emiting the last
char. The TUI already takes care of things like that, for terminals
where it matters.