mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
patch 8.0.1037: "icase" of 'diffopt' is not used for highlighting
Problem: "icase" of 'diffopt' is not used for highlighting differences. Solution: Also use "icase". (Rick Howe)
This commit is contained in:
57
src/diff.c
57
src/diff.c
@@ -1949,6 +1949,40 @@ diffopt_horizontal(void)
|
||||
return (diff_flags & DIFF_HORIZONTAL) != 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare the characters at "p1" and "p2". If they are equal (possibly
|
||||
* ignoring case) return TRUE and set "len" to the number of bytes.
|
||||
*/
|
||||
static int
|
||||
diff_equal_char(char_u *p1, char_u *p2, int *len)
|
||||
{
|
||||
#ifdef FEAT_MBYTE
|
||||
int l = (*mb_ptr2len)(p1);
|
||||
|
||||
if (l != (*mb_ptr2len)(p2))
|
||||
return FALSE;
|
||||
if (l > 1)
|
||||
{
|
||||
if (STRNCMP(p1, p2, l) != 0
|
||||
&& (!enc_utf8
|
||||
|| !(diff_flags & DIFF_ICASE)
|
||||
|| utf_fold(utf_ptr2char(p1))
|
||||
!= utf_fold(utf_ptr2char(p2))))
|
||||
return FALSE;
|
||||
*len = l;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if ((*p1 != *p2)
|
||||
&& (!(diff_flags & DIFF_ICASE)
|
||||
|| TOLOWER_LOC(*p1) != TOLOWER_LOC(*p2)))
|
||||
return FALSE;
|
||||
*len = 1;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the difference within a changed line.
|
||||
* Returns TRUE if the line was added, no other buffer has it.
|
||||
@@ -1969,6 +2003,10 @@ diff_find_change(
|
||||
int idx;
|
||||
int off;
|
||||
int added = TRUE;
|
||||
#ifdef FEAT_MBYTE
|
||||
char_u *p1, *p2;
|
||||
int l;
|
||||
#endif
|
||||
|
||||
/* Make a copy of the line, the next ml_get() will invalidate it. */
|
||||
line_org = vim_strsave(ml_get_buf(wp->w_buffer, lnum, FALSE));
|
||||
@@ -2017,10 +2055,11 @@ diff_find_change(
|
||||
}
|
||||
else
|
||||
{
|
||||
if (line_org[si_org] != line_new[si_new])
|
||||
if (!diff_equal_char(line_org + si_org, line_new + si_new,
|
||||
&l))
|
||||
break;
|
||||
++si_org;
|
||||
++si_new;
|
||||
si_org += l;
|
||||
si_new += l;
|
||||
}
|
||||
}
|
||||
#ifdef FEAT_MBYTE
|
||||
@@ -2056,10 +2095,16 @@ diff_find_change(
|
||||
}
|
||||
else
|
||||
{
|
||||
if (line_org[ei_org] != line_new[ei_new])
|
||||
p1 = line_org + ei_org;
|
||||
p2 = line_new + ei_new;
|
||||
#ifdef FEAT_MBYTE
|
||||
p1 -= (*mb_head_off)(line_org, p1);
|
||||
p2 -= (*mb_head_off)(line_new, p2);
|
||||
#endif
|
||||
if (!diff_equal_char(p1, p2, &l))
|
||||
break;
|
||||
--ei_org;
|
||||
--ei_new;
|
||||
ei_org -= l;
|
||||
ei_new -= l;
|
||||
}
|
||||
}
|
||||
if (*endp < ei_org)
|
||||
|
Reference in New Issue
Block a user