From f49408454ddb48016d51b48bcd9d5dab538f5cc7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 10 Apr 2024 07:08:49 +0800 Subject: vim-patch:9.1.0296: regexp: engines do not handle case-folding well (#28259) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Regex engines do not handle case-folding well Solution: Correctly calculate byte length of characters to skip When the regexp engine compares two utf-8 codepoints case insensitively it may match an adjacent character, because it assumes it can step over as many bytes as the pattern contains. This however is not necessarily true because of case-folding, a multi-byte UTF-8 character can be considered equal to some single-byte value. Let's consider the pattern 'ſ' and the string 's'. When comparing and ignoring case, the single character 's' matches, and since it matches Vim will try to step over the match (by the amount of bytes of the pattern), assuming that since it matches, the length of both strings is the same. However in that case, it should only step over the single byte value 's' so by 1 byte and try to start matching after it again. So for the backtracking engine we need to ensure: - we try to match the correct length for the pattern and the text - in case of a match, we step over it correctly The same thing can happen for the NFA engine, when skipping to the next character to test for a match. We are skipping over the regstart pointer, however we do not consider the case that because of case-folding we may need to adjust the number of bytes to skip over. So this needs to be adjusted in find_match_text() as well. A related issue turned out, when prog->match_text is actually empty. In that case we should try to find the next match and skip this condition. fixes: vim/vim#14294 closes: vim/vim#14433 https://github.com/vim/vim/commit/7a27c108e0509f3255ebdcb6558e896c223e4d23 Co-authored-by: Christian Brabandt --- src/nvim/mbyte.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index c7a56209e4..0a7bb78102 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1387,7 +1387,7 @@ bool mb_isalpha(int a) return mb_islower(a) || mb_isupper(a); } -static int utf_strnicmp(const char *s1, const char *s2, size_t n1, size_t n2) +int utf_strnicmp(const char *s1, const char *s2, size_t n1, size_t n2) { int c1, c2; char buffer[6]; -- cgit From d0afb2dc4eb8e70942441b3c9a551dcccd6806cd Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 11 Apr 2024 07:40:16 +0800 Subject: vim-patch:9.1.0297: Patch 9.1.0296 causes too many issues (#28263) Problem: Patch 9.1.0296 causes too many issues (Tony Mechelynck, chdiza, CI) Solution: Back out the change for now Revert "patch 9.1.0296: regexp: engines do not handle case-folding well" This reverts commit 7a27c108e0509f3255ebdcb6558e896c223e4d23 it causes issues with syntax highlighting and breaks the FreeBSD and MacOS CI. It needs more work. fixes: vim/vim#14487 https://github.com/vim/vim/commit/c97f4d61cde24030f2f7d2318e1b409a0ccc3e43 Co-authored-by: Christian Brabandt --- src/nvim/mbyte.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 0a7bb78102..c7a56209e4 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -1387,7 +1387,7 @@ bool mb_isalpha(int a) return mb_islower(a) || mb_isupper(a); } -int utf_strnicmp(const char *s1, const char *s2, size_t n1, size_t n2) +static int utf_strnicmp(const char *s1, const char *s2, size_t n1, size_t n2) { int c1, c2; char buffer[6]; -- cgit From 6685481dfa68e690dafb14c9f8570ac29293f9da Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 15 Apr 2024 06:11:30 +0800 Subject: vim-patch:9.1.0320: Wrong cursor position after using setcellwidths() (#28334) Problem: Wrong cursor position after using setcellwidths(). Solution: Invalidate cursor position in addition to redrawing. (zeertzjq) closes: vim/vim#14545 https://github.com/vim/vim/commit/05aacec6ab5c7ed8a13bbdca2f0005d6a1816230 Reorder functions in test_utf8.vim to match upstream. --- src/nvim/mbyte.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/mbyte.c') diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index c7a56209e4..a345795bbe 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -59,6 +59,7 @@ #include "nvim/memline.h" #include "nvim/memory.h" #include "nvim/message.h" +#include "nvim/move.h" #include "nvim/option_vars.h" #include "nvim/optionstr.h" #include "nvim/os/os.h" @@ -2878,6 +2879,7 @@ void f_setcellwidths(typval_T *argvars, typval_T *rettv, EvalFuncData fptr) } xfree(cw_table_save); + changed_window_setting_all(); redraw_all_later(UPD_NOT_VALID); } -- cgit