neovim/src/nvim
zeertzjq e0259b9466 vim-patch:9.1.0423: getregionpos() wrong with blockwise mode and multibyte
Problem:  getregionpos() wrong with blockwise mode and multibyte.
Solution: Use textcol and textlen instead of start_vcol and end_vcol.
          Handle coladd properly (zeertzjq).

Also remove unnecessary buflist_findnr() in add_regionpos_range(), as
getregionpos() has already switched buffer.

closes: vim/vim#14805

c95e64f41f
2024-05-20 20:59:54 +08:00
..
api feat(api): broadcast events to ALL channels #28487 2024-05-17 07:37:39 -07:00
eval vim-patch:9.1.0423: getregionpos() wrong with blockwise mode and multibyte 2024-05-20 20:59:54 +08:00
event fix: adjust error message for error in UI event callback (#28200) 2024-04-06 11:18:43 +08:00
generators fix(version): fix vim.version().prerelease 2024-05-16 20:10:54 +02:00
lib refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
lua perf(treesitter): use child_containing_descendant() in has-ancestor? (#28512) 2024-05-16 16:57:58 +02:00
msgpack_rpc feat(api): broadcast events to ALL channels #28487 2024-05-17 07:37:39 -07:00
os fix(path): avoid chdir() when resolving path (#28799) 2024-05-17 18:39:01 +08:00
po docs: fix typos (#27868) 2024-03-28 09:32:32 +08:00
tui fix(tui): initialize clear attrs with current terminal background 2024-05-10 14:13:02 +02:00
viml/parser refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
CMakeLists.txt perf(treesitter): use child_containing_descendant() in has-ancestor? (#28512) 2024-05-16 16:57:58 +02:00
README.md docs: various #25289 2024-01-18 00:14:48 -08:00
arabic.c perf: don't decode utf8 character multiple times in getvcol() 2024-01-22 09:04:42 +08:00
arabic.h build(IWYU): remove arabic_defs.h (#26235) 2023-11-27 07:41:43 +08:00
arglist.c vim-patch:9.1.0147: Cannot keep a buffer focused in a window 2024-03-11 11:38:13 +08:00
arglist.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
arglist_defs.h refactor: remove redundant struct names 2024-01-02 21:59:12 +01:00
ascii_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
assert_defs.h refactor: remove redundant NOLINT comments 2024-01-01 19:57:44 +01:00
auevents.lua vim-patch:9.1.0207: No autocommand when writing session file (#28048) 2024-03-27 05:41:41 +08:00
autocmd.c fix(api): ignore 'autochdir' when renaming other buf (#28376) 2024-04-16 20:57:01 +08:00
autocmd.h vim-patch:9.1.0231: Filetype may be undetected when SwapExists sets ft in other buf (#28136) 2024-04-01 06:12:11 +08:00
autocmd_defs.h vim-patch:9.1.0272: autocmd may change cwd after :tcd and :lcd (#28223) 2024-04-08 06:25:22 +08:00
base64.c fix(base64): properly handle embedded NULLs when decoding (#28349) 2024-04-15 11:06:54 -05:00
base64.h refactor: move Arena and ArenaMem to memory_defs.h (#26240) 2023-11-27 17:21:58 +08:00
buffer.c vim-patch:9.1.0231: Filetype may be undetected when SwapExists sets ft in other buf (#28136) 2024-04-01 06:12:11 +08:00
buffer.h refactor: IWYU (#27186) 2024-01-25 07:57:21 +08:00
buffer_defs.h vim-patch:9.1.0374: wrong botline in BufEnter (#28530) 2024-04-27 06:32:25 +08:00
buffer_updates.c refactor(lua): use Arena when converting from lua stack to API args 2024-02-13 11:54:44 +01:00
buffer_updates.h refactor: move some constants out of vim_defs.h (#26298) 2023-11-29 20:32:40 +08:00
bufwrite.c refactor(backup): remove duplicate os_copy_xattr() (#28020) 2024-03-25 14:39:00 +08:00
bufwrite.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
change.c refactor(change): check all tabpages in changed_lines_invalidate_buf() (#28666) 2024-05-08 14:00:45 +08:00
change.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
channel.c docs: misc #24163 2024-04-30 04:30:21 -07:00
channel.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
channel_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
charset.c vim-patch:9.1.0313: Crash when using heredoc with comment in command block 2024-04-14 05:06:50 +08:00
charset.h refactor: run IWYU on entire repo 2023-12-21 17:38:42 +01:00
cmdexpand.c refactor(path.c): add nonnull attributes (#28829) 2024-05-19 05:38:31 +08:00
cmdexpand.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
cmdexpand_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
cmdhist.c refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
cmdhist.h refactor: remove redundant struct names 2024-01-02 21:59:12 +01:00
context.c refactor(eval): use arena when converting typvals to Object 2024-02-15 10:42:06 +01:00
context.h refactor: move some constants out of vim_defs.h (#26298) 2023-11-29 20:32:40 +08:00
cursor.c docs: misc (#28609) 2024-05-15 07:18:33 +08:00
cursor.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
cursor_shape.c refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
cursor_shape.h refactor: remove redundant struct names 2024-01-02 21:59:12 +01:00
debugger.c refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
debugger.h refactor: move Arena and ArenaMem to memory_defs.h (#26240) 2023-11-27 17:21:58 +08:00
decoration.c fix(api): make getting explicit empty hl in virtual text work (#28697) 2024-05-12 05:39:33 +08:00
decoration.h revert: "feat(extmarks): subpriorities (relative to declaration order) (#27131)" (#28585) 2024-05-01 08:08:22 -05:00
decoration_defs.h fix(api): make getting explicit empty hl in virtual text work (#28697) 2024-05-12 05:39:33 +08:00
decoration_provider.c test: silence expected errors 2024-04-02 17:07:44 +02:00
decoration_provider.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
diff.c refactor(options): remove `set_string_option_direct()` 2024-03-21 15:41:14 +06:00
diff.h refactor(IWYU): fix includes for cmdhist.h (#26324) 2023-11-30 22:48:15 +08:00
digraph.c vim-patch:9.0.2180: POSIX function name in exarg causes issues (#28308) 2024-04-13 06:39:30 +08:00
digraph.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
drawline.c vim-patch:9.1.0418: Cannot move to previous/next rare word (#28822) 2024-05-18 07:09:05 +08:00
drawline.h refactor: remove CPO_TO_CPO_FLAGS() (#26718) 2023-12-23 15:53:28 +08:00
drawscreen.c feat(api): add nvim__redraw for more granular redrawing 2024-05-02 15:57:06 +02:00
drawscreen.h vim-patch:9.0.0245: mechanism to prevent recursive screen updating is incomplete (#27448) 2024-02-13 06:30:35 +08:00
edit.c vim-patch:9.1.0251: Filetype test fails (#28142) 2024-04-01 21:49:44 +08:00
edit.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
eval.c Merge pull request #28492 from bfredl/hotfix 2024-04-25 08:58:58 +02:00
eval.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
eval.lua vim-patch:9.1.0423: getregionpos() wrong with blockwise mode and multibyte 2024-05-20 20:59:54 +08:00
eval_defs.h refactor(IWYU): move evalarg_T to eval_defs.h (#26716) 2023-12-23 08:28:17 +08:00
ex_cmds.c vim-patch:9.0.2180: POSIX function name in exarg causes issues (#28308) 2024-04-13 06:39:30 +08:00
ex_cmds.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
ex_cmds.lua vim-patch:9.1.0381: cbuffer and similar commands don't accept a range (#28571) 2024-04-30 06:02:38 +08:00
ex_cmds2.c vim-patch:9.0.2180: POSIX function name in exarg causes issues (#28308) 2024-04-13 06:39:30 +08:00
ex_cmds2.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
ex_cmds_defs.h vim-patch:9.0.2180: POSIX function name in exarg causes issues (#28308) 2024-04-13 06:39:30 +08:00
ex_docmd.c docs: misc (#28609) 2024-05-15 07:18:33 +08:00
ex_docmd.h refactor(IWYU): move typedefs out of globals.h (#26322) 2023-11-30 19:52:23 +08:00
ex_eval.c refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
ex_eval.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
ex_eval_defs.h refactor(IWYU): move typedefs out of globals.h (#26322) 2023-11-30 19:52:23 +08:00
ex_getln.c fix(ui): avoid recursiveness and invalid memory access #28578 2024-05-01 13:51:06 -07:00
ex_getln.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
ex_getln_defs.h refactor(IWYU): create {ex_getln,rbuffer,os/fileio}_defs.h (#26338) 2023-12-01 08:06:37 +08:00
ex_session.c refactor: add xmemcpyz() and use it in place of some xstrlcpy() (#28422) 2024-04-20 19:31:00 +08:00
ex_session.h refactor: move Arena and ArenaMem to memory_defs.h (#26240) 2023-11-27 17:21:58 +08:00
extmark.c perf(extmarks): better track whether namespace has extmarks (#28615) 2024-05-03 18:02:25 +08:00
extmark.h refactor(extmarks): remove unused new pos from ExtmarkSavePos 2024-01-18 19:54:45 +01:00
extmark_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
file_search.c refactor: add xmemcpyz() and use it in place of some xstrlcpy() (#28422) 2024-04-20 19:31:00 +08:00
file_search.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
fileio.c vim-patch:9.1.0231: Filetype may be undetected when SwapExists sets ft in other buf (#28136) 2024-04-01 06:12:11 +08:00
fileio.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
fold.c refactor: add xmemcpyz() and use it in place of some xstrlcpy() (#28422) 2024-04-20 19:31:00 +08:00
fold.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
fold_defs.h refactor: remove redundant struct names 2024-01-02 21:59:12 +01:00
func_attr.h refactor(api): make freeing of return-value opt-in instead of opt out 2024-02-21 11:58:28 +01:00
garray.c refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
garray.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
garray_defs.h refactor: remove redundant struct names 2024-01-02 21:59:12 +01:00
getchar.c vim-patch:9.1.0365: Crash when typing many keys with D- modifier (#28464) 2024-04-23 08:18:42 +08:00
getchar.h refactor(fileio): remove API shell layer encouraging unnecessary allocations 2024-02-25 11:20:06 +01:00
getchar_defs.h refactor: remove redundant struct names 2024-01-02 21:59:12 +01:00
gettext_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
globals.h vim-patch:9.1.0231: Filetype may be undetected when SwapExists sets ft in other buf (#28136) 2024-04-01 06:12:11 +08:00
grid.c docs: misc (#28609) 2024-05-15 07:18:33 +08:00
grid.h vim-patch:9.1.0184: Cursor pos wrong when clicking with conceal and wrap (#27890) 2024-03-17 07:26:39 +08:00
grid_defs.h vim-patch:9.1.0186: cursor pos wrong on mouse click after eol with 'rl', 've' and conceal (#27903) 2024-03-18 10:35:41 +08:00
hashtab.c refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
hashtab.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
hashtab_defs.h refactor: remove redundant struct names 2024-01-02 21:59:12 +01:00
help.c refactor(options): remove `set_string_option_direct()` 2024-03-21 15:41:14 +06:00
help.h refactor: move Arena and ArenaMem to memory_defs.h (#26240) 2023-11-27 17:21:58 +08:00
highlight.c refactor(ui): remove outdated UI vs UIData distinction 2024-03-08 09:23:28 +01:00
highlight.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
highlight_defs.h feat(ui): add support for OSC 8 hyperlinks (#27109) 2024-01-24 16:36:25 -06:00
highlight_group.c docs: misc (#28609) 2024-05-15 07:18:33 +08:00
highlight_group.h fix(highlight): add `Nvim{Light,Dark}Gray{1,2,3,4}` colors 2024-03-30 14:31:46 +02:00
iconv_defs.h refactor: fix headers with IWYU 2023-11-28 22:23:56 +01:00
indent.c vim-patch:9.1.0218: Unnecessary multiplications in backspace code (#28075) 2024-03-28 18:20:38 +08:00
indent.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
indent_c.c docs: misc (#28609) 2024-05-15 07:18:33 +08:00
indent_c.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
input.c vim-patch:9.0.2114: overflow detection not accurate when adding digits (#28271) 2024-04-11 09:34:43 +08:00
input.h refactor(options): generate BV_ and WV_ constants (#26705) 2023-12-22 12:24:23 +08:00
insexpand.c vim-patch:9.1.0418: Cannot move to previous/next rare word (#28822) 2024-05-18 07:09:05 +08:00
insexpand.h refactor(IWYU): move typedefs out of globals.h (#26322) 2023-11-30 19:52:23 +08:00
keycodes.c vim-patch:9.1.0073: Looping over modifier_keys_table unnecessarily 2024-02-04 06:46:09 +08:00
keycodes.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
linematch.c refactor: fix headers with IWYU 2023-11-28 22:23:56 +01:00
linematch.h refactor: fix runtime_defs.h (#26259) 2023-11-28 07:47:36 +08:00
log.c refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
log.h refactor: run IWYU on entire repo 2023-12-21 17:38:42 +01:00
macros_defs.h perf: don't decode utf8 character multiple times in getvcol() 2024-01-22 09:04:42 +08:00
main.c fix(treesitter): make tests for memoize more robust 2024-04-29 16:20:46 +02:00
main.h refactor: run IWYU on entire repo 2023-12-21 17:38:42 +01:00
map.c fix(column): keep track of number of lines with number of signs 2024-01-15 09:37:53 +00:00
map_defs.h feat(ui): add support for OSC 8 hyperlinks (#27109) 2024-01-24 16:36:25 -06:00
map_glyph_cache.c refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
map_key_impl.c.h refactor: fix headers with IWYU 2023-11-28 22:23:56 +01:00
map_value_impl.c.h refactor: fix headers with IWYU 2023-11-28 22:23:56 +01:00
mapping.c docs: misc (#28609) 2024-05-15 07:18:33 +08:00
mapping.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
mapping_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
mark.c fix(api): fix set_lines viewport adjustment, but this time good 2024-03-14 10:56:24 +01:00
mark.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
mark_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
marktree.c docs: small fixes (#27364) 2024-03-12 13:51:53 +08:00
marktree.h feat(extmark): window scoped extmark 2024-02-21 16:11:50 +01:00
marktree_defs.h perf(extmarks): add metadata for efficient filtering of special decorations 2024-01-22 19:03:32 +01:00
match.c vim-patch:9.1.0340: Problem: Error with matchaddpos() and empty list (#28381) 2024-04-17 06:49:23 +08:00
match.h refactor: fix runtime_defs.h (#26259) 2023-11-28 07:47:36 +08:00
math.c feat(api): add nvim__redraw for more granular redrawing 2024-05-02 15:57:06 +02:00
math.h refactor(options): remove option type macros 2023-12-14 16:46:42 +06:00
mbyte.c vim-patch:9.1.0320: Wrong cursor position after using setcellwidths() (#28334) 2024-04-15 06:11:30 +08:00
mbyte.h fix(mbyte): fix bugs in utf_cp_*_off() functions 2024-02-26 18:12:55 +08:00
mbyte_defs.h docs: fix typos (#27868) 2024-03-28 09:32:32 +08:00
memfile.c perf(extmarks): better track whether namespace has extmarks (#28615) 2024-05-03 18:02:25 +08:00
memfile.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
memfile_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
memline.c fix(terminal): disable reflow again 2024-03-14 19:22:16 +08:00
memline.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
memline_defs.h vim-patch:9.1.0138: too many STRLEN calls when getting a memline (#27799) 2024-03-10 17:08:00 +08:00
memory.c refactor: add function attributes to xmemcpyz() (#28435) 2024-04-21 16:44:40 +08:00
memory.h refactor(msgpack): allow flushing buffer while packing msgpack 2024-03-07 09:39:46 +01:00
memory_defs.h refactor: move Arena and ArenaMem to memory_defs.h (#26240) 2023-11-27 17:21:58 +08:00
menu.c fix(api/buffer): fix handling of viewport of non-current buffer 2024-03-13 07:19:59 +01:00
menu.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
menu_defs.h refactor: replace manual header guards with #pragma once 2023-11-12 22:01:28 +01:00
message.c fix(messages): avoid passing negative length to strnlen() (#28753) 2024-05-15 19:38:50 +08:00
message.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
message_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
mouse.c vim-patch:9.1.0406: Divide by zero with getmousepos() and 'smoothscroll' (#28701) 2024-05-11 17:46:22 +08:00
mouse.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
move.c fix(move): half-page scrolling with resized grid at eob (#28821) 2024-05-18 07:00:29 +08:00
move.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
normal.c vim-patch:9.1.0418: Cannot move to previous/next rare word (#28822) 2024-05-18 07:09:05 +08:00
normal.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
normal_defs.h refactor: remove redundant struct names 2024-01-02 21:59:12 +01:00
ops.c vim-patch:9.1.0423: getregionpos() wrong with blockwise mode and multibyte 2024-05-20 20:59:54 +08:00
ops.h vim-patch:9.1.0120: hard to get visual region using Vim script 2024-02-23 06:39:03 +08:00
option.c vim-patch:9.1.0231: Filetype may be undetected when SwapExists sets ft in other buf (#28136) 2024-04-01 06:12:11 +08:00
option.h refactor(options): swap `immutable` and `hidden` option property names 2024-03-27 09:27:16 +00:00
option_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
option_vars.h vim-patch:9.1.0277: Cannot highlight the Command-line (#28244) 2024-04-09 07:20:49 +08:00
options.lua docs: misc #24163 2024-04-30 04:30:21 -07:00
optionstr.c refactor(options): remove `set_string_option_direct()` 2024-03-21 15:41:14 +06:00
optionstr.h refactor(options): use schar_T representation for fillchars and listchars 2024-01-08 14:37:55 +01:00
path.c refactor(path.c): add nonnull attributes (#28829) 2024-05-19 05:38:31 +08:00
path.h refactor(IWYU): fix includes for cmdhist.h (#26324) 2023-11-30 22:48:15 +08:00
plines.c vim-patch:9.1.0413: smoothscroll may cause infinite loop (#28763) 2024-05-16 05:36:24 +08:00
plines.h docs: small fixes (#27213) 2024-02-06 19:30:02 +08:00
popupmenu.c refactor: add win_T argument to setcursor_mayforce() 2024-05-02 15:46:15 +02:00
popupmenu.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
pos_defs.h refactor(IWYU): move typedefs out of globals.h (#26322) 2023-11-30 19:52:23 +08:00
profile.c refactor: reduce some globals #27406 2024-02-10 05:00:17 -08:00
profile.h refactor: fix runtime_defs.h (#26259) 2023-11-28 07:47:36 +08:00
quickfix.c vim-patch:9.1.0397: Wrong display with 'smoothscroll' when changing quickfix list (#28674) 2024-05-09 06:11:56 +08:00
quickfix.h refactor: eliminate cyclic includes 2023-12-20 19:52:02 +01:00
rbuffer.c fix(rpc): do not crash when no input is consumed 2024-03-21 15:52:28 +01:00
rbuffer.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
rbuffer_defs.h refactor(IWYU): create {ex_getln,rbuffer,os/fileio}_defs.h (#26338) 2023-12-01 08:06:37 +08:00
regexp.c vim-patch:9.1.0409: too many strlen() calls in the regexp engine (#28857) 2024-05-20 12:42:57 +08:00
regexp.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
regexp_defs.h refactor: move structs from regexp_defs.h to regexp.c (#26899) 2024-01-05 22:26:07 +08:00
runtime.c refactor(source): remove unnecessary concatenation with Lua (#28499) 2024-04-25 08:26:49 +08:00
runtime.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
runtime_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
search.c docs: misc (#28609) 2024-05-15 07:18:33 +08:00
search.h refactor: remove redundant struct names 2024-01-02 21:59:12 +01:00
sha256.c refactor: move function macros out of vim_defs.h (#26300) 2023-11-29 23:10:21 +08:00
sha256.h refactor: move Arena and ArenaMem to memory_defs.h (#26240) 2023-11-27 17:21:58 +08:00
shada.c refactor(msgpack): allow flushing buffer while packing msgpack 2024-03-07 09:39:46 +01:00
shada.h refactor: move Arena and ArenaMem to memory_defs.h (#26240) 2023-11-27 17:21:58 +08:00
sign.c feat(extmark): window scoped extmark 2024-02-21 16:11:50 +01:00
sign.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
sign_defs.h fix(column): use a single path for sign sorting (#27431) 2024-02-12 06:41:44 +08:00
spell.c vim-patch:9.1.0418: Cannot move to previous/next rare word (#28822) 2024-05-18 07:09:05 +08:00
spell.h vim-patch:9.1.0418: Cannot move to previous/next rare word (#28822) 2024-05-18 07:09:05 +08:00
spell_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
spellfile.c refactor: add xmemcpyz() and use it in place of some xstrlcpy() (#28422) 2024-04-20 19:31:00 +08:00
spellfile.h refactor: move Arena and ArenaMem to memory_defs.h (#26240) 2023-11-27 17:21:58 +08:00
spellsuggest.c vim-patch:9.1.0418: Cannot move to previous/next rare word (#28822) 2024-05-18 07:09:05 +08:00
spellsuggest.h build(clint): more precise check for "defs" headers (#26236) 2023-11-27 08:34:06 +08:00
state.c vim-patch:9.1.0259: Normal mode TextChanged isn't tested properly (#28167) 2024-04-04 06:11:17 +08:00
state.h fix(api/buffer): fix handling of viewport of non-current buffer 2024-03-13 07:19:59 +01:00
state_defs.h refactor: move some constants out of vim_defs.h (#26298) 2023-11-29 20:32:40 +08:00
statusline.c refactor(options): remove `set_string_option_direct()` 2024-03-21 15:41:14 +06:00
statusline.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
statusline_defs.h refactor(column): define and use maximum 'statuscolumn' width 2024-01-04 11:52:37 +00:00
strings.c vim-patch:9.1.0409: too many strlen() calls in the regexp engine (#28857) 2024-05-20 12:42:57 +08:00
strings.h vim-patch:9.1.0409: too many strlen() calls in the regexp engine (#28857) 2024-05-20 12:42:57 +08:00
syntax.c refactor: add xmemcpyz() and use it in place of some xstrlcpy() (#28422) 2024-04-20 19:31:00 +08:00
syntax.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
syntax_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
tag.c refactor: add xmemcpyz() and use it in place of some xstrlcpy() (#28422) 2024-04-20 19:31:00 +08:00
tag.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
terminal.c feat(lua): pass keys before mapping to vim.on_key() callback (#28098) 2024-03-31 11:20:05 +08:00
terminal.h refactor(IWYU): move decor provider types to decoration_defs.h (#26692) 2023-12-21 16:50:05 +08:00
testing.c refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
testing.h refactor: fix runtime_defs.h (#26259) 2023-11-28 07:47:36 +08:00
textformat.c revert: "vim-patch:9.1.0055: formatting long lines is slow" 2024-04-06 12:04:24 +08:00
textformat.h refactor(IWYU): create normal_defs.h (#26293) 2023-11-29 12:10:42 +08:00
textobject.c vim-patch:9.1.0172: More code can use ml_get_buf_len() instead of STRLEN() 2024-03-14 13:09:54 +08:00
textobject.h refactor(IWYU): move typedefs out of globals.h (#26322) 2023-11-30 19:52:23 +08:00
types_defs.h fix(column): keep track of number of lines with number of signs 2024-01-15 09:37:53 +00:00
ugrid.c refactor: follow style guide 2023-11-13 23:39:56 +01:00
ugrid.h refactor: remove redundant struct names 2024-01-02 21:59:12 +01:00
ui.c fix(ui): avoid recursiveness and invalid memory access #28578 2024-05-01 13:51:06 -07:00
ui.h fix(ui): avoid recursiveness and invalid memory access #28578 2024-05-01 13:51:06 -07:00
ui_client.c fix(ui_client): check return value of channel_job_start (#27729) 2024-03-04 13:15:04 +00:00
ui_client.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
ui_compositor.c refactor(ui): remove outdated UI vs UIData distinction 2024-03-08 09:23:28 +01:00
ui_compositor.h refactor(IWYU): move UI and LineFlags to ui_defs.h (#26318) 2023-11-30 17:16:57 +08:00
ui_defs.h fix(ui): avoid recursiveness and invalid memory access #28578 2024-05-01 13:51:06 -07:00
undo.c fix(api/buffer): fix handling of viewport of non-current buffer 2024-03-13 07:19:59 +01:00
undo.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
undo_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
usercmd.c vim-patch:9.0.2180: POSIX function name in exarg causes issues (#28308) 2024-04-13 06:39:30 +08:00
usercmd.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
version.c version.c: update [skip ci] (#28201) 2024-04-06 11:15:08 +08:00
version.h refactor: eliminate cyclic includes 2023-12-20 19:52:02 +01:00
vim_defs.h refactor(IWYU): fix headers 2024-01-11 21:37:23 +01:00
vvars.lua docs: various fixes (#28208) 2024-04-30 07:04:42 +08:00
window.c vim-patch:9.1.0374: wrong botline in BufEnter (#28530) 2024-04-27 06:32:25 +08:00
window.h feat(api): make nvim_open_win support non-floating windows (#25550) 2024-02-01 11:43:35 +08:00
winfloat.c fix(completion): improve popup window position (#26739) 2024-04-25 21:36:18 +08:00
winfloat.h refactor: move float_relative_str[] to nvim_win_get_config() (#26344) 2023-12-01 16:37:09 +08:00

README.md

Nvim core

Module-specific details are documented at the top of each module (terminal.c, undo.c, …).

See :help dev for guidelines.

Filename conventions

The source files use extensions to hint about their purpose.

  • *.c, *.generated.c - full C files, with all includes, etc.
  • *.c.h - parametrized C files, contain all necessary includes, but require defining macros before actually using. Example: typval_encode.c.h
  • *.h - full headers, with all includes. Does not apply to *.generated.h.
  • *.h.generated.h - exported functions declarations.
  • *.c.generated.h - static functions declarations.

Common structures

  • StringBuilder
  • kvec or garray.c for dynamic lists / vectors (use StringBuilder for strings)

Logs

Low-level log messages sink to $NVIM_LOG_FILE.

UI events are logged at DEBUG level.

rm -rf build/
make CMAKE_EXTRA_FLAGS="-DLOG_DEBUG"

Use LOG_CALLSTACK() (Linux only) to log the current stacktrace. To log to an alternate file (e.g. stderr) use LOG_CALLSTACK_TO_FILE(FILE*). Requires -no-pie (ref):

rm -rf build/
make CMAKE_EXTRA_FLAGS="-DLOG_DEBUG -DCMAKE_C_FLAGS=-no-pie"

Many log messages have a shared prefix, such as "UI" or "RPC". Use the shell to filter the log, e.g. at DEBUG level you might want to exclude UI messages:

tail -F ~/.local/state/nvim/log | cat -v | stdbuf -o0 grep -v UI | stdbuf -o0 tee -a log

Build with ASAN

Building Nvim with Clang sanitizers (Address Sanitizer: ASan, Undefined Behavior Sanitizer: UBSan, Memory Sanitizer: MSan, Thread Sanitizer: TSan) is a good way to catch undefined behavior, leaks and other errors as soon as they happen. It's significantly faster than Valgrind.

Requires clang 3.4 or later, and llvm-symbolizer must be in $PATH:

clang --version

Build Nvim with sanitizer instrumentation (choose one):

CC=clang make CMAKE_EXTRA_FLAGS="-DENABLE_ASAN_UBSAN=ON"
CC=clang make CMAKE_EXTRA_FLAGS="-DENABLE_MSAN=ON"
CC=clang make CMAKE_EXTRA_FLAGS="-DENABLE_TSAN=ON"

Create a directory to store logs:

mkdir -p "$HOME/logs"

Configure the sanitizer(s) via these environment variables:

# Change to detect_leaks=1 to detect memory leaks (slower, noisier).
export ASAN_OPTIONS="detect_leaks=0:log_path=$HOME/logs/asan"
# Show backtraces in the logs.
export MSAN_OPTIONS="log_path=${HOME}/logs/msan"
export TSAN_OPTIONS="log_path=${HOME}/logs/tsan"

Logs will be written to ${HOME}/logs/*san.PID then.

For more information: https://github.com/google/sanitizers/wiki/SanitizerCommonFlags

Reproducible build

To make a reproducible build of Nvim, set cmake variable LUA_GEN_PRG to a LuaJIT binary built with LUAJIT_SECURITY_PRN=0. See commit cb757f2663.

Debug: Performance

Profiling (easy)

For debugging performance bottlenecks in any code, there is a simple (and very effective) approach:

  1. Run the slow code in a loop.
  2. Break execution ~5 times and save the stacktrace.
  3. The cause of the bottleneck will (almost always) appear in most of the stacktraces.

Profiling (fancy)

For more advanced profiling, consider perf + flamegraph.

USDT profiling (powerful)

Or you can use USDT probes via NVIM_PROBE (#12036).

USDT is basically a way to define stable probe points in userland binaries. The benefit of bcc is the ability to define logic to go along with the probe points.

Tools:

  • bpftrace provides an awk-like language to the kernel bytecode, BPF.
  • BCC provides a subset of C. Provides more complex logic than bpftrace, but takes a bit more effort.

Example using bpftrace to track slow vim functions, and print out any files that were opened during the trace. At the end, it prints a histogram of function timing:

#!/usr/bin/env bpftrace

BEGIN {
  @depth = -1;
}

tracepoint:sched:sched_process_fork /@pidmap[args->parent_pid]/ {
  @pidmap[args->child_pid] = 1;
}

tracepoint:sched:sched_process_exit /@pidmap[args->pid]/ {
  delete(@pidmap[args->pid]);
}

usdt:build/bin/nvim:neovim:eval__call_func__entry {
    @pidmap[pid] = 1;
    @depth++;
    @funcentry[@depth] = nsecs;
}

usdt:build/bin/nvim:neovim:eval__call_func__return {
    $func = str(arg0);
    $msecs = (nsecs - @funcentry[@depth]) / 1000000;

    @time_histo = hist($msecs);

    if ($msecs >= 1000) {
      printf("%u ms for %s\n", $msecs, $func);
      print(@files);
    }

    clear(@files);
    delete(@funcentry[@depth]);
    @depth--;
}

tracepoint:syscalls:sys_enter_open,
tracepoint:syscalls:sys_enter_openat {
  if (@pidmap[pid] == 1 && @depth >= 0) {
    @files[str(args->filename)] = count();
  }
}

END {
  clear(@depth);
}

$ sudo bpftrace funcslower.bt
1527 ms for Slower
@files[/usr/lib/libstdc++.so.6]: 2
@files[/etc/fish/config.fish]: 2
<snip>

^C
@time_histo:
[0]                71430 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
[1]                  346 |                                                    |
[2, 4)               208 |                                                    |
[4, 8)                91 |                                                    |
[8, 16)               22 |                                                    |
[16, 32)              85 |                                                    |
[32, 64)               7 |                                                    |
[64, 128)              0 |                                                    |
[128, 256)             0 |                                                    |
[256, 512)             6 |                                                    |
[512, 1K)              1 |                                                    |
[1K, 2K)               5 |                                                    |

Debug: TUI

TUI troubleshoot

Nvim logs its internal terminfo state at 'verbose' level 3. This makes it possible to see exactly what terminfo values Nvim is using on any system.

nvim -V3log

TUI Debugging with gdb/lldb

Launching the nvim TUI involves two processes, one for main editor state and one for rendering the TUI. Both of these processes use the nvim binary, so somewhat confusingly setting a breakpoint in either will generally succeed but may not be hit depending on which process the breakpoints were set in.

To debug the main process, you can debug the nvim binary with the --headless flag which does not launch the TUI and will allow you to set breakpoints in code not related to TUI rendering like so:

lldb -- ./build/bin/nvim --headless --listen ~/.cache/nvim/debug-server.pipe

While in lldb, enter run. You can then attach to the headless process in a new terminal window to interact with the editor like so:

./build/bin/nvim --remote-ui --server ~/.cache/nvim/debug-server.pipe

Conversely for debugging TUI rendering, you can start a headless process and debug the remote-ui process multiple times without losing editor state.

For details on using nvim-dap and automatically debugging the child (main) process, see here

TUI trace

The ancient script command is still the "state of the art" for tracing terminal behavior. The libvterm vterm-dump utility formats the result for human-readability.

Record a Nvim terminal session and format it with vterm-dump:

script foo
./build/bin/nvim -u NONE
# Exit the script session with CTRL-d

# Use `vterm-dump` utility to format the result.
./.deps/usr/bin/vterm-dump foo > bar

Then you can compare bar with another session, to debug TUI behavior.

TUI redraw

Set the 'writedelay' and 'redrawdebug' options to see where and when the UI is painted.

:set writedelay=50 rdb=compositor

Note: neovim uses an internal screenbuffer to only send minimal updates even if a large region is repainted internally. To also highlight excess internal redraws, use

:set writedelay=50 rdb=compositor,nodelta

Terminal reference

Data structures

Buffer text is stored as a tree of line segments, defined in memline.c. The central idea is found in ml_find_line.

Nvim lifecycle

Following describes how Nvim processes input.

Consider a typical Vim-like editing session:

  1. Vim displays the welcome screen
  2. User types: :
  3. Vim enters command-line mode
  4. User types: edit README.txt<CR>
  5. Vim opens the file and returns to normal mode
  6. User types: G
  7. Vim navigates to the end of the file
  8. User types: 5
  9. Vim enters count-pending mode
  10. User types: d
  11. Vim enters operator-pending mode
  12. User types: w
  13. Vim deletes 5 words
  14. User types: g
  15. Vim enters the "g command mode"
  16. User types: g
  17. Vim goes to the beginning of the file
  18. User types: i
  19. Vim enters insert mode
  20. User types: word<ESC>
  21. Vim inserts "word" at the beginning and returns to normal mode

Note that we split user actions into sequences of inputs that change the state of the editor. While there's no documentation about a "g command mode" (step 16), internally it is implemented similarly to "operator-pending mode".

From this we can see that Vim has the behavior of an input-driven state machine (more specifically, a pushdown automaton since it requires a stack for transitioning back from states). Assuming each state has a callback responsible for handling keys, this pseudocode represents the main program loop:

def state_enter(state_callback, data):
  do
    key = readkey()                 # read a key from the user
  while state_callback(data, key)   # invoke the callback for the current state

That is, each state is entered by calling state_enter and passing a state-specific callback and data. Here is a high-level pseudocode for a program that implements something like the workflow described above:

def main()
  state_enter(normal_state, {}):

def normal_state(data, key):
  if key == ':':
    state_enter(command_line_state, {})
  elif key == 'i':
    state_enter(insert_state, {})
  elif key == 'd':
    state_enter(delete_operator_state, {})
  elif key == 'g':
    state_enter(g_command_state, {})
  elif is_number(key):
    state_enter(get_operator_count_state, {'count': key})
  elif key == 'G'
    jump_to_eof()
  return true

def command_line_state(data, key):
  if key == '<cr>':
    if data['input']:
      execute_ex_command(data['input'])
    return false
  elif key == '<esc>'
    return false

  if not data['input']:
    data['input'] = ''

  data['input'] += key
  return true

def delete_operator_state(data, key):
  count = data['count'] or 1
  if key == 'w':
    delete_word(count)
  elif key == '$':
    delete_to_eol(count)
  return false  # return to normal mode

def g_command_state(data, key):
  if key == 'g':
    go_top()
  elif key == 'v':
    reselect()
  return false  # return to normal mode

def get_operator_count_state(data, key):
  if is_number(key):
    data['count'] += key
    return true
  unshift_key(key)  # return key to the input buffer
  state_enter(delete_operator_state, data)
  return false

def insert_state(data, key):
  if key == '<esc>':
    return false  # exit insert mode
  self_insert(key)
  return true

The above gives an idea of how Nvim is organized internally. Some states like the g_command_state or get_operator_count_state do not have a dedicated state_enter callback, but are implicitly embedded into other states (this will change later as we continue the refactoring effort). To start reading the actual code, here's the recommended order:

  1. state_enter() function (state.c). This is the actual program loop, note that a VimState structure is used, which contains function pointers for the callback and state data.
  2. main() function (main.c). After all startup, normal_enter is called at the end of function to enter normal mode.
  3. normal_enter() function (normal.c) is a small wrapper for setting up the NormalState structure and calling state_enter.
  4. normal_check() function (normal.c) is called before each iteration of normal mode.
  5. normal_execute() function (normal.c) is called when a key is read in normal mode.

The basic structure described for normal mode in 3, 4 and 5 is used for other modes managed by the state_enter loop:

  • command-line mode: command_line_{enter,check,execute}()(ex_getln.c)
  • insert mode: insert_{enter,check,execute}()(edit.c)
  • terminal mode: terminal_{enter,execute}()(terminal.c)

Important variables

The current mode is stored in State. The values it can have are MODE_NORMAL, MODE_INSERT, MODE_CMDLINE, and a few others.

The current window is curwin. The current buffer is curbuf. These point to structures with the cursor position in the window, option values, the file name, etc.

All the global variables are declared in globals.h.

The main loop

The main loop is implemented in state_enter. The basic idea is that Vim waits for the user to type a character and processes it until another character is needed. Thus there are several places where Vim waits for a character to be typed. The vgetc() function is used for this. It also handles mapping.

Updating the screen is mostly postponed until a command or a sequence of commands has finished. The work is done by update_screen(), which calls win_update() for every window, which calls win_line() for every line. See the start of drawscreen.c for more explanations.

Command-line mode

When typing a :, normal_cmd() will call getcmdline() to obtain a line with an Ex command. getcmdline() calls a loop that will handle each typed character. It returns when hitting <CR> or <Esc> or some other character that ends the command line mode.

Ex commands

Ex commands are handled by the function do_cmdline(). It does the generic parsing of the : command line and calls do_one_cmd() for each separate command. It also takes care of while loops.

do_one_cmd() parses the range and generic arguments and puts them in the exarg_t and passes it to the function that handles the command.

The : commands are listed in ex_cmds.lua.

Normal mode commands

The Normal mode commands are handled by the normal_cmd() function. It also handles the optional count and an extra character for some commands. These are passed in a cmdarg_T to the function that handles the command.

There is a table nv_cmds in normal.c which lists the first character of every command. The second entry of each item is the name of the function that handles the command.

Insert mode commands

When doing an i or a command, normal_cmd() will call the edit() function. It contains a loop that waits for the next character and handles it. It returns when leaving Insert mode.

Options

There is a list with all option names in options.lua.

Async event support

One of the features Nvim added is the support for handling arbitrary asynchronous events, which can include:

  • RPC requests
  • job control callbacks
  • timers

Nvim implements this functionality by entering another event loop while waiting for characters, so instead of:

def state_enter(state_callback, data):
  do
    key = readkey()                 # read a key from the user
  while state_callback(data, key)   # invoke the callback for the current state

Nvim program loop is more like:

def state_enter(state_callback, data):
  do
    event = read_next_event()       # read an event from the operating system
  while state_callback(data, event) # invoke the callback for the current state

where event is something the operating system delivers to us, including (but not limited to) user input. The read_next_event() part is internally implemented by libuv, the platform layer used by Nvim.

Since Nvim inherited its code from Vim, the states are not prepared to receive "arbitrary events", so we use a special key to represent those (When a state receives an "arbitrary event", it normally doesn't do anything other than update the screen).

Main loop

The Loop structure (which describes main_loop) abstracts multiple queues into one loop:

uv_loop_t uv;
MultiQueue *events;
MultiQueue *thread_events;
MultiQueue *fast_events;

loop_poll_events checks Loop.uv and Loop.fast_events whenever Nvim is idle, and also at os_breakcheck intervals.

MultiQueue is cool because you can attach throw-away "child queues" trivially. For example do_os_system() does this (for every spawned process!) to automatically route events onto the main_loop:

Process *proc = &uvproc.process;
MultiQueue *events = multiqueue_new_child(main_loop.events);
proc->events = events;