aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2025-03-09 06:23:25 +0800
committerzeertzjq <zeertzjq@outlook.com>2025-03-27 07:26:42 +0800
commitcd95ea5d48daa271e323b1eee862e25b49d379d1 (patch)
tree00d61a38de7e69d1370740b38d5ea8e88a5fb7df /src
parent10fde593f177fb7655c5f1c2b9774509e90c6106 (diff)
downloadrneovim-cd95ea5d48daa271e323b1eee862e25b49d379d1.tar.gz
rneovim-cd95ea5d48daa271e323b1eee862e25b49d379d1.tar.bz2
rneovim-cd95ea5d48daa271e323b1eee862e25b49d379d1.zip
vim-patch:9.1.1185: endless loop with completefuzzycollect and no match found
Problem: endless loop with completefuzzycollect and no match found Solution: move pointer to line end and break loop closes: vim/vim#16820 https://github.com/vim/vim/commit/dd42b05f8a37df03a9b77a16a47c08ab33af2b1f Co-authored-by: glepnir <glephunter@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/nvim/insexpand.c4
-rw-r--r--src/nvim/search.c10
2 files changed, 8 insertions, 6 deletions
diff --git a/src/nvim/insexpand.c b/src/nvim/insexpand.c
index 0b85fc23e8..0e8b135812 100644
--- a/src/nvim/insexpand.c
+++ b/src/nvim/insexpand.c
@@ -1735,8 +1735,6 @@ static void ins_compl_files(int count, char **files, bool thesaurus, int flags,
&& score == compl_first_match->cp_next->cp_score) {
compl_num_bests++;
}
- } else if (find_word_end(ptr) == line_end) {
- break;
}
}
}
@@ -1778,7 +1776,7 @@ char *find_word_end(char *ptr)
/// Find the end of the line, omitting CR and NL at the end.
///
/// @return a pointer to just after the line.
-static char *find_line_end(char *ptr)
+char *find_line_end(char *ptr)
{
char *s = ptr + strlen(ptr);
while (s > ptr && (s[-1] == CAR || s[-1] == NL)) {
diff --git a/src/nvim/search.c b/src/nvim/search.c
index b31263e127..2b7739292b 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -3629,8 +3629,7 @@ garray_T *fuzzy_match_str_with_pos(char *const str, const char *const pat)
/// - `*len` is set to the length of the matched word.
/// - `*score` contains the match score.
///
-/// If no match is found, `*ptr` is updated to point beyond the last word
-/// or to the end of the line.
+/// If no match is found, `*ptr` is updated to to the end of the line.
bool fuzzy_match_str_in_line(char **ptr, char *pat, int *len, pos_T *current_pos, int *score)
{
char *str = *ptr;
@@ -3642,8 +3641,9 @@ bool fuzzy_match_str_in_line(char **ptr, char *pat, int *len, pos_T *current_pos
if (str == NULL || pat == NULL) {
return found;
}
+ char *line_end = find_line_end(str);
- while (*str != NUL) {
+ while (str < line_end) {
// Skip non-word characters
start = find_word_start(str);
if (*start == NUL) {
@@ -3677,6 +3677,10 @@ bool fuzzy_match_str_in_line(char **ptr, char *pat, int *len, pos_T *current_pos
}
}
+ if (!found) {
+ *ptr = line_end;
+ }
+
return found;
}