Commit Graph

27496 Commits

Author SHA1 Message Date
sisrfeng
37da0bc0c6
docs: clarify about error in shada (#25594) 2023-10-11 17:58:07 +08:00
Raphael
f79052faef
refactor(float): rename ex_floatclose to ex_fclose (#25596) 2023-10-11 15:03:59 +08:00
zeertzjq
4eea60939f
test(core/path_spec): don't use fnameescape() (#25593)
Using fnameescape() for the path argument of findfile() and finddir() is
wrong, as fnameescape() is intended to be used for parts of Ex commands,
not function arguments.
2023-10-11 07:24:37 +08:00
Famiu Haque
c4f8be464c docs(style): add guideline for fixing compiler error on switch statement
Problem: Certain compilers (primarily GCC) do not recognize an exhaustive enum switch statement as being exhaustive. This manifests in the form of compiler errors in exhaustive switch statements where each case has a return statement but there isn't a catch-all return statements. These compiler errors are spurious in the context of the Neovim codebase. So #25533 added the `UNREACHABLE` macro to denote apart of the code that's unreachable, which was used after every such switch statement to tell the compiler to treat the switch statement as exhaustive. However, the macro is mentioned nowhere in the style guide,and new contributors would not have any natural way of learning about it as it stands now. This would lead to confusion when they inevitably encounter one of these compiler errors.

Solution: Add a style guideline which shows how to use the `UNREACHABLE` macro to fix these compiler errors.
2023-10-10 22:23:54 +02:00
dundargoc
c3d21ad1bc docs: small fixes
Co-authored-by: Wansmer <wansmer@gmail.com>
Co-authored-by: Andrew Voynov <andrewvoynov.b@gmail.com>
Co-authored-by: David Moberg <david.moberg@mediatek.com>
2023-10-10 19:20:32 +02:00
bfredl
fd39f5ce8c
Merge pull request #25561 from glepnir/9663
feat(float): add fclose command
2023-10-10 16:36:55 +02:00
James
468a3a1407
refactor: use xstpcpy() instead of strcat() (#25572) 2023-10-10 22:03:55 +08:00
glepnir
372aa2eb3d feat(float): add fclose command 2023-10-10 21:17:08 +08:00
Famiu Haque
9ff6f73f83 refactor: allow not having a default case for enum
Problem: The style guide states that all switch statements that are not conditional on an enum must have a `default` case, but does not give any explicit guideline for switch statements that are conditional on enums. As a result, a `default` case is added in many enum switch statements, even when the switch statement is exhaustive. This is not ideal because it removes the ability to have compiler errors to easily detect unchanged switch statements when a new possible value for an enum is added.

Solution: Add explicit guidelines for switch statements that are conditional on an enum, clarifying that a `default` case is not necessary if the switch statement is exhaustive. Also refactor pre-existing code with unnecessary `default` cases.
2023-10-10 11:19:41 +01:00
Evgeni Chasnovski
a2f17e97ec
fix(highlight): add FloatFooter to 'highlight_defs.h' (#25577) 2023-10-10 17:33:30 +08:00
zeertzjq
c40a1c0f41
vim-patch:9.0.2009: cmdline-completion for comma-separated options wrong (#25569)
Problem:  cmdline-completion for comma-separated options wrong
Solution: Fix command-line expansions for options with filenames with
          commas

Fix command-line expansions for options with filenames with commas

Cmdline expansion for option values that take a comma-separated list
of file names is currently not handling file names with commas as the
commas are not escaped. For such options, the commas in file names need
to be escaped (to differentiate from a comma that delimit the list
items). The escaped comma is unescaped in `copy_option_part()` during
option parsing.

Fix as follows:
- Cmdline completion for option values with comma-separated file/folder
  names will not start a new match when seeing `\\,` and will instead
  consider it as one value.
- File/folder regex matching will strip the `\\` when seeing `\\,` to
  make sure it can match the correct files/folders.
- The expanded value will escape `,` with `\\,`, similar to how spaces
  are escaped to make sure the option value is correct on the cmdline.

This fix also takes into account the fact that Win32 Vim handles file
name escaping differently. Typing '\,' for a file name results in it
being handled literally but in other platforms '\,' is interpreted as a
simple ',' and commas need to be escaped using '\\,' instead.

Also, make sure this new logic only applies to comma-separated options
like 'path'. Non-list options like 'set makeprg=<Tab>' and regular ex
commands like `:edit <Tab>` do not require escaping and will continue to
work.

Also fix up documentation to be clearer. The original docs are slightly
misleading in how it discusses triple slashes for 'tags'.

closes: vim/vim#13303
related: vim/vim#13301

54844857fd

Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2023-10-10 09:15:21 +08:00
zeertzjq
f5eabaa940
fix(path): restore space separation in 'path' (#25571)
Removing this behavior causes more inconsistencies and bugs.
2023-10-10 08:22:32 +08:00
zeertzjq
43f22853fe
docs: fix misplaced mention of 'backupdir' (#25568) 2023-10-10 07:06:34 +08:00
Maria José Solano
c80a3976cb
docs: miscellaneous doc and type fixes (#25554) 2023-10-10 06:34:48 +08:00
Leonardo Mello
81f67b79e8
fix(file_search): path with spaces in finddir() and findfile() (#25493)
Co-authored-by: dundargoc <gocdundar@gmail.com>
2023-10-10 06:08:58 +08:00
zeertzjq
4ab2b43c8f
vim-patch:9.0.2008: test: undofile left behind (#25567)
Problem:  test: undofile left behind
Solution: cleanup undofile

fix: tmp file not deleted when running make test_undo

Temporary file `.Xtestfile.txt.un~` was left running `make test_undo`
and vim was configured with:
```
./configure --with-features=normal --enable-gui=no --enable-terminal
```

closes: vim/vim#13304

b07b9dc4da

Co-authored-by: Dominique Pellé <dominique.pelle@tomtom.com>
2023-10-10 05:56:28 +08:00
dundargoc
40bd96b6f9 ci: use clang 17 as the default clang version is too old 2023-10-09 21:52:56 +02:00
dundargoc
9eb5d9f13f ci: various cleanups
- add reviewers
- correct cache key
2023-10-09 20:27:48 +02:00
dundargoc
6c0f900699 ci: enable clang-analyzer warnings
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.
2023-10-09 16:52:28 +02:00
Justin M. Keyes
55be4a4e26
fix(coverity): dead code #25562
*** 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;
2023-10-09 06:05:36 -07:00
Christian Clason
307a7abf86 build(deps): bump libmpack-lua to 1.0.11
update vendored libmpack-lua to match

https://github.com/libmpack/libmpack-lua/releases/tag/1.0.11
2023-10-09 12:37:15 +02:00
ii14
139e6f68f9
fix(autocmd): API functions accept garbage after event name #25523
"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>
2023-10-09 02:50:44 -07:00
dundargoc
8e932480f6 refactor: the long goodbye
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.
2023-10-09 11:45:46 +02:00
Jaehoon Hwang
dacd34364f
feat(ui-ext): make 'mousehide' into proper ui_option (#25532) 2023-10-09 16:48:24 +08:00
zeertzjq
f96f8566b5
test(ui/embed_spec): use notification instead of request (#25555)
This avoid the hang mentioned in #24888, and also matches TUI better.
2023-10-09 16:14:37 +08:00
Christian Clason
dadc06ced2 build(deps): bump luajit to HEAD - 656ecbcf8 2023-10-09 09:25:26 +02:00
bfredl
61f1e992ce
Merge pull request #25503 from bfredl/unishape
refactor(grid): do arabic shaping in one place
2023-10-08 23:32:24 +02:00
Christian Clason
e5855697e9 vim-patch:1e33cd72b60a
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>
2023-10-08 23:31:49 +02:00
bfredl
ddef39299f refactor(grid): do arabic shaping in one place
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.
2023-10-08 15:22:45 +02:00
dundargoc
30d311ebcf fix(PVS/V592): expression is enclosed by parentheses twice 2023-10-08 12:36:39 +02:00
dundargoc
1bbbca267d fix(PVS/V547): expression is always true/false 2023-10-08 12:36:39 +02:00
LW
9abced6ad9
fix(lsp): account for border height in max floating popup height (#25539) 2023-10-08 10:09:25 +02:00
dundargoc
6823fdb20b build(PVS): exclude build directory
This is to prevent reports on generated files.
2023-10-07 22:02:30 +02:00
bfredl
506d119c16
Merge pull request #25533 from famiu/docs/style/abort-default
docs: use `abort()` for unreachable `default:` case in C
2023-10-07 20:57:55 +02:00
dundargoc
753adcc66c ci: fix mac release 2023-10-07 18:25:43 +02:00
Famiu Haque
380870335f docs: use abort() for unreachable default: case in C
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.
2023-10-07 20:47:55 +06:00
bfredl
1f864139b2
Merge pull request #25522 from glepnir/4334
fix(ui): trigger TabNewEntered after split new tab
2023-10-07 11:10:28 +02:00
glepnir
1cd7824dd6 fix(ui): trigger TabNewEntered after split new tab 2023-10-07 16:40:57 +08:00
dundargoc
7f65431d90 vim-patch:9.0.1997: Some unused code in move.c and string.c
Problem:  Some unused code in move.c and string.c
Solution: Remove it

closes: vim/vim#13288

580c1fcb4a

Co-authored-by: dundargoc <gocdundar@gmail.com>
2023-10-07 10:11:22 +02:00
zeertzjq
7e9407490c
Merge pull request #25529 from zeertzjq/vim-9.0.1990
vim-patch:9.0.1990,27e12c7669e3
2023-10-07 07:01:55 +08:00
Christian Clason
e7c268e38f vim-patch:2a281ccca017
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>
2023-10-07 00:48:35 +02:00
zeertzjq
1ac588543d
vim-patch:9.0.1995: Invalid memory access with empty 'foldexpr' (#25530)
Problem:  Invalid memory access when 'foldexpr' returns empty string.
Solution: Check for NUL.

closes: vim/vim#13293

a991ce9c08
2023-10-07 06:32:06 +08:00
zeertzjq
92df389f1b vim-patch:27e12c7669e3
runtime(doc): remove E1520 tag (vim/vim#13289)

27e12c7669
2023-10-07 05:54:12 +08:00
zeertzjq
8bb0878013 vim-patch:9.0.1990: strange error number
Problem:  strange error number
Solution: change error number,
          add doc tag for E1507

closes: vim/vim#13270

ea746f9e86

Co-authored-by: Christ van Willegen <cvwillegen@gmail.com>
2023-10-07 05:54:10 +08:00
Aayush Ojha
5db076c7cc
fix(lua): vim.region on linewise selection #25467
fixes #18155
2023-10-06 05:44:50 -07:00
Justin M. Keyes
01374446af
Merge #25236 from lsvmello/fix-gf 2023-10-06 05:39:36 -07:00
Justin M. Keyes
133e2990ef refactor: cleanup 2023-10-06 14:09:21 +02:00
Justin M. Keyes
56dc8b9212 fix: heap-buffer-overflow in file_name_in_line
heap-buffer-overflow on address 0x6020000079cf at pc 0x563e98bd70b6 bp 0x7ffc52efc430 sp 0x7ffc52efbbf8
    = READ of size 1 at 0x6020000079cf thread T0
    =     0 0x563e98bd70b5 in strlen (/home/runner/work/neovim/neovim/build/bin/nvim+0xc7b0b5) (BuildId: e40ec79ca4eae53c0155aeb03de88ddd5d29c5d2)
    =     1 0x563e99da4f45 in path_has_drive_letter /home/runner/work/neovim/neovim/src/nvim/path.c:1754:10
    =     2 0x563e9a610d81 in file_name_in_line /home/runner/work/neovim/neovim/src/nvim/window.c:6951:49
    =     3 0x563e9a61066f in file_name_at_cursor /home/runner/work/neovim/neovim/src/nvim/window.c:6917:10
    =     4 0x563e995a08d6 in eval_vars /home/runner/work/neovim/neovim/src/nvim/ex_docmd.c:6903:16
    =     5 0x563e9937c648 in f_expand /home/runner/work/neovim/neovim/src/nvim/eval/funcs.c:1754:20
    =     6 0x563e99357819 in call_internal_func /home/runner/work/neovim/neovim/src/nvim/eval/funcs.c:273:3
    =     7 0x563e994656de in call_func /home/runner/work/neovim/neovim/src/nvim/eval/userfunc.c:1719:15
    =     8 0x563e99461ae6 in get_func_tv /home/runner/work/neovim/neovim/src/nvim/eval/userfunc.c:557:11
    =     9 0x563e992c7c5d in eval_func /home/runner/work/neovim/neovim/src/nvim/eval.c:2281:13
    =     10 0x563e992bf708 in eval7 /home/runner/work/neovim/neovim/src/nvim/eval.c:3208:15
    =     11 0x563e992bbda9 in eval6 /home/runner/work/neovim/neovim/src/nvim/eval.c:2935:7
    =     12 0x563e992b9e8d in eval5 /home/runner/work/neovim/neovim/src/nvim/eval.c:2791:7
    =     13 0x563e992b87e2 in eval4 /home/runner/work/neovim/neovim/src/nvim/eval.c:2666:7
    =     14 0x563e992b758d in eval3 /home/runner/work/neovim/neovim/src/nvim/eval.c:2575:7
    =     15 0x563e9926299d in eval2 /home/runner/work/neovim/neovim/src/nvim/eval.c:2497:7
    =     16 0x563e99250b0c in eval1 /home/runner/work/neovim/neovim/src/nvim/eval.c:2401:7
    =     17 0x563e9924d68a in eval0 /home/runner/work/neovim/neovim/src/nvim/eval.c:2346:9
    =     18 0x563e98f17315 in nvim_eval /home/runner/work/neovim/neovim/src/nvim/api/vimscript.c:170:3
    =     19 0x563e98e7bb5e in handle_nvim_eval /home/runner/work/neovim/neovim/build/src/nvim/auto/api/private/dispatch_wrappers.generated.h:8953:15
    =     20 0x563e99b62f59 in request_event /home/runner/work/neovim/neovim/src/nvim/msgpack_rpc/channel.c:444:19
    =     21 0x563e9a1dcdc9 in state_handle_k_event /home/runner/work/neovim/neovim/src/nvim/state.c:115:7
    =     22 0x563e99bf0718 in nv_event /home/runner/work/neovim/neovim/src/nvim/normal.c:6623:3
    =     23 0x563e99bb4069 in normal_execute /home/runner/work/neovim/neovim/src/nvim/normal.c:1227:3
    =     24 0x563e9a1dcb8d in state_enter /home/runner/work/neovim/neovim/src/nvim/state.c:97:26
    =     25 0x563e99b9673c in normal_enter /home/runner/work/neovim/neovim/src/nvim/normal.c:516:3
    =     26 0x563e98c82e0d in main /home/runner/work/neovim/neovim/src/nvim/main.c:643:3
    =     27 0x7fcb81429d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f) (BuildId: 229b7dc509053fe4df5e29e8629911f0c3bc66dd)
    =     28 0x7fcb81429e3f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e3f) (BuildId: 229b7dc509053fe4df5e29e8629911f0c3bc66dd)
    =     29 0x563e98bc0f74 in _start (/home/runner/work/neovim/neovim/build/bin/nvim+0xc64f74) (BuildId: e40ec79ca4eae53c0155aeb03de88ddd5d29c5d2)
    =
    = 0x6020000079cf is located 1 bytes to the left of 9-byte region [0x6020000079d0,0x6020000079d9)
    = allocated by thread T0 here:
    =     0 0x563e98c43dbe in __interceptor_malloc (/home/runner/work/neovim/neovim/build/bin/nvim+0xce7dbe) (BuildId: e40ec79ca4eae53c0155aeb03de88ddd5d29c5d2)
    =     1 0x563e99a7b6f6 in try_malloc /home/runner/work/neovim/neovim/src/nvim/memory.c:89:15
    =     2 0x563e99a7b8dc in xmalloc /home/runner/work/neovim/neovim/src/nvim/memory.c:123:15
    =     3 0x563e9901ace2 in ins_str /home/runner/work/neovim/neovim/src/nvim/change.c:801:16
    =     4 0x563e99208133 in insertchar /home/runner/work/neovim/neovim/src/nvim/edit.c:2172:5
    =     5 0x563e9921936c in insert_special /home/runner/work/neovim/neovim/src/nvim/edit.c:1995:5
    =     6 0x563e99218e9f in insert_handle_key /home/runner/work/neovim/neovim/src/nvim/edit.c:1173:7
    =     7 0x563e991f0f1d in insert_execute /home/runner/work/neovim/neovim/src/nvim/edit.c:671:10
    =     8 0x563e9a1dcb8d in state_enter /home/runner/work/neovim/neovim/src/nvim/state.c:97:26
    =     9 0x563e991f8c75 in insert_enter /home/runner/work/neovim/neovim/src/nvim/edit.c:338:5
    =     10 0x563e991ed4e2 in edit /home/runner/work/neovim/neovim/src/nvim/edit.c:1270:3
    =     11 0x563e99bf6007 in invoke_edit /home/runner/work/neovim/neovim/src/nvim/normal.c:6269:7
    =     12 0x563e99bcb665 in nv_edit /home/runner/work/neovim/neovim/src/nvim/normal.c:6246:5
    =     13 0x563e99bb4069 in normal_execute /home/runner/work/neovim/neovim/src/nvim/normal.c:1227:3
    =     14 0x563e9a1dcb8d in state_enter /home/runner/work/neovim/neovim/src/nvim/state.c:97:26
    =     15 0x563e99b9673c in normal_enter /home/runner/work/neovim/neovim/src/nvim/normal.c:516:3
    =     16 0x563e98c82e0d in main /home/runner/work/neovim/neovim/src/nvim/main.c:643:3
    =     17 0x7fcb81429d8f  (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f) (BuildId: 229b7dc509053fe4df5e29e8629911f0c3bc66dd)
2023-10-06 14:09:21 +02:00
Leonardo Mello
1dd700a8d9 fix: gf fails on "foo/bar.txt:1:2" on Windows
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
2023-10-06 12:59:58 +02:00
bfredl
4e4ad4312e
Merge pull request #25513 from bfredl/cleangrid
refactor(grid): get rid of unbatched grid_puts and grid_putchar
2023-10-06 11:21:46 +02:00