diff options
Diffstat (limited to 'src/spellsuggest.c')
-rw-r--r-- | src/spellsuggest.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/spellsuggest.c b/src/spellsuggest.c index ecc0a74..c6e6183 100644 --- a/src/spellsuggest.c +++ b/src/spellsuggest.c @@ -508,9 +508,8 @@ spell_suggest(int count) ++badlen; end_visual_mode(); // make sure we don't include the NUL at the end of the line - line = ml_get_curline(); - if (badlen > (int)STRLEN(line) - (int)curwin->w_cursor.col) - badlen = (int)STRLEN(line) - (int)curwin->w_cursor.col; + if (badlen > ml_get_curline_len() - (int)curwin->w_cursor.col) + badlen = ml_get_curline_len() - (int)curwin->w_cursor.col; } // Find the start of the badly spelled word. else if (spell_move_to(curwin, FORWARD, TRUE, TRUE, NULL) == 0 @@ -543,7 +542,7 @@ spell_suggest(int count) curwin->w_cursor.col); // Make a copy of current line since autocommands may free the line. - line = vim_strsave(ml_get_curline()); + line = vim_strnsave(ml_get_curline(), ml_get_curline_len()); if (line == NULL) goto skip; @@ -3763,11 +3762,16 @@ sug_compare(const void *s1, const void *s2) { suggest_T *p1 = (suggest_T *)s1; suggest_T *p2 = (suggest_T *)s2; - int n = p1->st_score - p2->st_score; + int n; + + n = p1->st_score == p2->st_score ? 0 : + p1->st_score > p2->st_score ? 1 : -1; if (n == 0) { - n = p1->st_altscore - p2->st_altscore; + n = p1->st_altscore == p2->st_altscore ? 0 : + p1->st_altscore > p2->st_altscore ? 1 : -1; + if (n == 0) n = STRICMP(p1->st_word, p2->st_word); } |