From 3d1110674ec330138ad6675f828673ca32575d4b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 7 Sep 2024 18:50:52 +0800 Subject: vim-patch:9.1.0720: Wrong breakindentopt=list:-1 with multibyte or TABs (#30293) Problem: Wrong breakindentopt=list:-1 with multibyte chars or TABs in text matched by 'formatlistpat' (John M Devin) Solution: Use the width of the match text (zeertzjq) fixes: vim/vim#15634 closes: vim/vim#15635 https://github.com/vim/vim/commit/61a6ac4d0066317131528f1b3ecc3b3a2599a75c --- src/nvim/indent.c | 12 +++++++++++- src/nvim/options.lua | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 895d0d9f37..b7e3842aad 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -891,7 +891,17 @@ int get_breakindent_win(win_T *wp, char *line) if (wp->w_briopt_list > 0) { prev_list += wp->w_briopt_list; } else { - prev_indent = (int)(*regmatch.endp - *regmatch.startp); + char *ptr = *regmatch.startp; + char *end_ptr = *regmatch.endp; + int indent = 0; + // Compute the width of the matched text. + // Use win_chartabsize() so that TAB size is correct, + // while wrapping is ignored. + while (ptr < end_ptr) { + indent += win_chartabsize(wp, ptr, indent); + MB_PTR_ADV(ptr); + } + prev_indent = indent; } } vim_regfree(regmatch.regprog); diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 1c17b0fc9f..71b0d26b49 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -761,9 +761,9 @@ return { list:{n} Adds an additional indent for lines that match a numbered or bulleted list (using the 'formatlistpat' setting). - list:-1 Uses the length of a match with 'formatlistpat' - for indentation. (default: 0) + list:-1 Uses the width of a match with 'formatlistpat' for + indentation. column:{n} Indent at column {n}. Will overrule the other sub-options. Note: an additional indent may be added for the 'showbreak' setting. -- cgit