Mercurial > vim
comparison src/diff.c @ 12315:40ee9f3d265f v8.0.1037
patch 8.0.1037: "icase" of 'diffopt' is not used for highlighting
commit https://github.com/vim/vim/commit/da22b8cc8b1b96fabd5a4c35c57b04a351340fb1
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Sep 2 18:01:50 2017 +0200
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 02 Sep 2017 18:15:04 +0200 |
parents | 1395a3b6978d |
children | dea5dda9ef30 |
comparison
equal
deleted
inserted
replaced
12314:09e2bcb44017 | 12315:40ee9f3d265f |
---|---|
1948 { | 1948 { |
1949 return (diff_flags & DIFF_HORIZONTAL) != 0; | 1949 return (diff_flags & DIFF_HORIZONTAL) != 0; |
1950 } | 1950 } |
1951 | 1951 |
1952 /* | 1952 /* |
1953 * Compare the characters at "p1" and "p2". If they are equal (possibly | |
1954 * ignoring case) return TRUE and set "len" to the number of bytes. | |
1955 */ | |
1956 static int | |
1957 diff_equal_char(char_u *p1, char_u *p2, int *len) | |
1958 { | |
1959 #ifdef FEAT_MBYTE | |
1960 int l = (*mb_ptr2len)(p1); | |
1961 | |
1962 if (l != (*mb_ptr2len)(p2)) | |
1963 return FALSE; | |
1964 if (l > 1) | |
1965 { | |
1966 if (STRNCMP(p1, p2, l) != 0 | |
1967 && (!enc_utf8 | |
1968 || !(diff_flags & DIFF_ICASE) | |
1969 || utf_fold(utf_ptr2char(p1)) | |
1970 != utf_fold(utf_ptr2char(p2)))) | |
1971 return FALSE; | |
1972 *len = l; | |
1973 } | |
1974 else | |
1975 #endif | |
1976 { | |
1977 if ((*p1 != *p2) | |
1978 && (!(diff_flags & DIFF_ICASE) | |
1979 || TOLOWER_LOC(*p1) != TOLOWER_LOC(*p2))) | |
1980 return FALSE; | |
1981 *len = 1; | |
1982 } | |
1983 return TRUE; | |
1984 } | |
1985 | |
1986 /* | |
1953 * Find the difference within a changed line. | 1987 * Find the difference within a changed line. |
1954 * Returns TRUE if the line was added, no other buffer has it. | 1988 * Returns TRUE if the line was added, no other buffer has it. |
1955 */ | 1989 */ |
1956 int | 1990 int |
1957 diff_find_change( | 1991 diff_find_change( |
1967 int ei_org, ei_new; | 2001 int ei_org, ei_new; |
1968 diff_T *dp; | 2002 diff_T *dp; |
1969 int idx; | 2003 int idx; |
1970 int off; | 2004 int off; |
1971 int added = TRUE; | 2005 int added = TRUE; |
2006 #ifdef FEAT_MBYTE | |
2007 char_u *p1, *p2; | |
2008 int l; | |
2009 #endif | |
1972 | 2010 |
1973 /* Make a copy of the line, the next ml_get() will invalidate it. */ | 2011 /* Make a copy of the line, the next ml_get() will invalidate it. */ |
1974 line_org = vim_strsave(ml_get_buf(wp->w_buffer, lnum, FALSE)); | 2012 line_org = vim_strsave(ml_get_buf(wp->w_buffer, lnum, FALSE)); |
1975 if (line_org == NULL) | 2013 if (line_org == NULL) |
1976 return FALSE; | 2014 return FALSE; |
2015 si_org = (int)(skipwhite(line_org + si_org) - line_org); | 2053 si_org = (int)(skipwhite(line_org + si_org) - line_org); |
2016 si_new = (int)(skipwhite(line_new + si_new) - line_new); | 2054 si_new = (int)(skipwhite(line_new + si_new) - line_new); |
2017 } | 2055 } |
2018 else | 2056 else |
2019 { | 2057 { |
2020 if (line_org[si_org] != line_new[si_new]) | 2058 if (!diff_equal_char(line_org + si_org, line_new + si_new, |
2059 &l)) | |
2021 break; | 2060 break; |
2022 ++si_org; | 2061 si_org += l; |
2023 ++si_new; | 2062 si_new += l; |
2024 } | 2063 } |
2025 } | 2064 } |
2026 #ifdef FEAT_MBYTE | 2065 #ifdef FEAT_MBYTE |
2027 if (has_mbyte) | 2066 if (has_mbyte) |
2028 { | 2067 { |
2054 && VIM_ISWHITE(line_new[ei_new])) | 2093 && VIM_ISWHITE(line_new[ei_new])) |
2055 --ei_new; | 2094 --ei_new; |
2056 } | 2095 } |
2057 else | 2096 else |
2058 { | 2097 { |
2059 if (line_org[ei_org] != line_new[ei_new]) | 2098 p1 = line_org + ei_org; |
2099 p2 = line_new + ei_new; | |
2100 #ifdef FEAT_MBYTE | |
2101 p1 -= (*mb_head_off)(line_org, p1); | |
2102 p2 -= (*mb_head_off)(line_new, p2); | |
2103 #endif | |
2104 if (!diff_equal_char(p1, p2, &l)) | |
2060 break; | 2105 break; |
2061 --ei_org; | 2106 ei_org -= l; |
2062 --ei_new; | 2107 ei_new -= l; |
2063 } | 2108 } |
2064 } | 2109 } |
2065 if (*endp < ei_org) | 2110 if (*endp < ei_org) |
2066 *endp = ei_org; | 2111 *endp = ei_org; |
2067 } | 2112 } |