fix: find multibyte file name in line (#20519)

And remove unnecessary unsigned casts in fold marker comparison.
This commit is contained in:
zeertzjq
2022-10-07 09:43:16 +08:00
committed by GitHub
parent d191070913
commit cfdb4cbada
4 changed files with 22 additions and 7 deletions

View File

@@ -3002,9 +3002,9 @@ static void foldlevelMarker(fline_T *flp)
// cache a few values for speed
char *startmarker = flp->wp->w_p_fmr;
int cstart = (unsigned char)(*startmarker);
char cstart = *startmarker;
startmarker++;
int cend = (unsigned char)(*foldendmarker);
char cend = *foldendmarker;
// Default: no start found, next level is same as current level
flp->start = 0;
@@ -3012,7 +3012,7 @@ static void foldlevelMarker(fline_T *flp)
char *s = ml_get_buf(flp->wp->w_buffer, flp->lnum + flp->off, false);
while (*s) {
if ((unsigned char)(*s) == cstart
if (*s == cstart
&& STRNCMP(s + 1, startmarker, foldstartmarkerlen - 1) == 0) {
// found startmarker: set flp->lvl
s += foldstartmarkerlen;
@@ -3032,7 +3032,7 @@ static void foldlevelMarker(fline_T *flp)
flp->lvl_next++;
flp->start++;
}
} else if ((unsigned char)(*s) == cend
} else if (*s == cend
&& STRNCMP(s + 1, foldendmarker + 1, foldendmarkerlen - 1) == 0) {
// found endmarker: set flp->lvl_next
s += foldendmarkerlen;