mirror of
https://github.com/neovim/neovim.git
synced 2025-09-13 06:48:17 +00:00
vim-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)
da22b8cc8b
This commit is contained in:
@@ -1870,6 +1870,35 @@ bool diffopt_horizontal(void)
|
|||||||
return (diff_flags & DIFF_HORIZONTAL) != 0;
|
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 bool diff_equal_char(const char_u *const p1, const char_u *const p2,
|
||||||
|
int *const len)
|
||||||
|
{
|
||||||
|
const int l = utfc_ptr2len(p1);
|
||||||
|
|
||||||
|
if (l != utfc_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 {
|
||||||
|
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.
|
/// Find the difference within a changed line.
|
||||||
///
|
///
|
||||||
/// @param wp window whose current buffer to check
|
/// @param wp window whose current buffer to check
|
||||||
@@ -1887,6 +1916,7 @@ bool diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
|
|||||||
int ei_org;
|
int ei_org;
|
||||||
int ei_new;
|
int ei_new;
|
||||||
bool added = true;
|
bool added = true;
|
||||||
|
int l;
|
||||||
|
|
||||||
// Make a copy of the line, the next ml_get() will invalidate it.
|
// Make a copy of the line, the next ml_get() will invalidate it.
|
||||||
char_u *line_org = vim_strsave(ml_get_buf(wp->w_buffer, lnum, FALSE));
|
char_u *line_org = vim_strsave(ml_get_buf(wp->w_buffer, lnum, FALSE));
|
||||||
@@ -1933,11 +1963,11 @@ bool diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
|
|||||||
si_org = (int)(skipwhite(line_org + si_org) - line_org);
|
si_org = (int)(skipwhite(line_org + si_org) - line_org);
|
||||||
si_new = (int)(skipwhite(line_new + si_new) - line_new);
|
si_new = (int)(skipwhite(line_new + si_new) - line_new);
|
||||||
} else {
|
} else {
|
||||||
if (line_org[si_org] != line_new[si_new]) {
|
if (!diff_equal_char(line_org + si_org, line_new + si_new, &l)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++si_org;
|
si_org += l;
|
||||||
++si_new;
|
si_new += l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1972,11 +2002,17 @@ bool diff_find_change(win_T *wp, linenr_T lnum, int *startp, int *endp)
|
|||||||
ei_new--;
|
ei_new--;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (line_org[ei_org] != line_new[ei_new]) {
|
const char_u *p1 = line_org + ei_org;
|
||||||
|
const char_u *p2 = line_new + ei_new;
|
||||||
|
|
||||||
|
p1 -= utf_head_off(line_org, p1);
|
||||||
|
p2 -= utf_head_off(line_new, p2);
|
||||||
|
|
||||||
|
if (!diff_equal_char(p1, p2, &l)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ei_org--;
|
ei_org -= l;
|
||||||
ei_new--;
|
ei_new -= l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -279,13 +279,13 @@ func Test_diffopt_icase()
|
|||||||
set diffopt=icase,foldcolumn:0
|
set diffopt=icase,foldcolumn:0
|
||||||
|
|
||||||
e one
|
e one
|
||||||
call setline(1, ['One', 'Two', 'Three', 'Four'])
|
call setline(1, ['One', 'Two', 'Three', 'Four', 'Fi#ve'])
|
||||||
redraw
|
redraw
|
||||||
let normattr = screenattr(1, 1)
|
let normattr = screenattr(1, 1)
|
||||||
diffthis
|
diffthis
|
||||||
|
|
||||||
botright vert new two
|
botright vert new two
|
||||||
call setline(1, ['one', 'TWO', 'Three ', 'Four'])
|
call setline(1, ['one', 'TWO', 'Three ', 'Four', 'fI=VE'])
|
||||||
diffthis
|
diffthis
|
||||||
|
|
||||||
redraw
|
redraw
|
||||||
@@ -294,6 +294,10 @@ func Test_diffopt_icase()
|
|||||||
call assert_notequal(normattr, screenattr(3, 1))
|
call assert_notequal(normattr, screenattr(3, 1))
|
||||||
call assert_equal(normattr, screenattr(4, 1))
|
call assert_equal(normattr, screenattr(4, 1))
|
||||||
|
|
||||||
|
let dtextattr = screenattr(5, 3)
|
||||||
|
call assert_notequal(dtextattr, screenattr(5, 1))
|
||||||
|
call assert_notequal(dtextattr, screenattr(5, 5))
|
||||||
|
|
||||||
diffoff!
|
diffoff!
|
||||||
%bwipe!
|
%bwipe!
|
||||||
set diffopt&
|
set diffopt&
|
||||||
|
Reference in New Issue
Block a user