diff --git a/uppsrc/CodeEditor/CodeEditor.cpp b/uppsrc/CodeEditor/CodeEditor.cpp index 9fc508b20..8d4c6a7ad 100644 --- a/uppsrc/CodeEditor/CodeEditor.cpp +++ b/uppsrc/CodeEditor/CodeEditor.cpp @@ -1033,13 +1033,17 @@ void CodeEditor::HighlightLine(int line, Vector& hl, int po if(q < 0) break; int n = illuminated.GetCount(); - while(n-- && q < hl.GetCount()) { - const HlStyle& st = hl_style[PAPER_SELWORD]; - hl[q].paper = st.color; - if(st.bold) - hl[q].font.Bold(); + if(n > 1 || !iscid(illuminated[0]) || + (q == 0 || !iscid(l[q - 1])) && (q + n >= l.GetCount() || !iscid(l[q + n]))) + while(n-- && q < hl.GetCount()) { + const HlStyle& st = hl_style[PAPER_SELWORD]; + hl[q].paper = st.color; + if(st.bold) + hl[q].font.Bold(); + q++; + } + else q++; - } } } } diff --git a/uppsrc/TextDiffCtrl/TextCtrl.cpp b/uppsrc/TextDiffCtrl/TextCtrl.cpp index 1fa206585..f3cfea42e 100644 --- a/uppsrc/TextDiffCtrl/TextCtrl.cpp +++ b/uppsrc/TextDiffCtrl/TextCtrl.cpp @@ -187,7 +187,7 @@ int TextCompareCtrl::GetMatchLen(const wchar *s1, const wchar *s2, int len) return len; } -void TextCompareCtrl::LineDiff(bool left, Vector& hln, Color eq_color, +bool TextCompareCtrl::LineDiff(bool left, Vector& hln, Color eq_color, const wchar *s1, int l1, int h1, const wchar *s2, int l2, int h2, int depth) { @@ -221,7 +221,9 @@ void TextCompareCtrl::LineDiff(bool left, Vector& hln, Colo LineDiff(left, hln, eq_color, s1, l1, p1, s2, l2, p2, depth); LineDiff(left, hln, eq_color, s1, p1 + matchlen, h1, s2, p2 + matchlen, h2, depth); } + return true; } + return false; } void TextCompareCtrl::Paint(Draw& draw) @@ -291,7 +293,6 @@ void TextCompareCtrl::Paint(Draw& draw) ink = SColorHighlightText; paper = SColorHighlight; } - draw.DrawRect(0, y, sz.cx, letter.cy, paper); WString ln = l.text.ToWString(); if(ln.GetCount() > 20000) @@ -306,6 +307,8 @@ void TextCompareCtrl::Paint(Draw& draw) h.chr = ln[i]; h.font = StdFont(); } + + bool ldiff = false; if(!sel) { WhenHighlight(hln, ln); @@ -320,11 +323,11 @@ void TextCompareCtrl::Paint(Draw& draw) ln_diff = ExpandTabs(ln_diff); if(ln_diff.GetCount() * ln.GetCount() < 50000) { if(left) - LineDiff(true, hln, SColorPaper(), - ~ln, 0, ln.GetCount(), ~ln_diff, 0, ln_diff.GetCount(), 0); + ldiff = LineDiff(true, hln, SColorPaper(), + ~ln, 0, ln.GetCount(), ~ln_diff, 0, ln_diff.GetCount(), 0); else - LineDiff(false, hln, SColorPaper(), - ~ln_diff, 0, ln_diff.GetCount(), ~ln, 0, ln.GetCount(), 0); + ldiff = LineDiff(false, hln, SColorPaper(), + ~ln_diff, 0, ln_diff.GetCount(), ~ln, 0, ln.GetCount(), 0); } } if(show_white_space) { @@ -338,8 +341,13 @@ void TextCompareCtrl::Paint(Draw& draw) break; } } + + if(ldiff) + paper = SColorPaper(); } + draw.DrawRect(0, y, sz.cx, letter.cy, paper); // paint the end of line + int x = 0; for(int i = 0; i < hln.GetCount() - 1; ++i) { Font fnt = font; diff --git a/uppsrc/TextDiffCtrl/TextDiffCtrl.h b/uppsrc/TextDiffCtrl/TextDiffCtrl.h index b65e297df..ff37be3d8 100644 --- a/uppsrc/TextDiffCtrl/TextDiffCtrl.h +++ b/uppsrc/TextDiffCtrl/TextDiffCtrl.h @@ -51,7 +51,7 @@ private: void Copy(); int GetLineNo(int y, int& yy); int GetMatchLen(const wchar *s1, const wchar *s2, int len); - void LineDiff(bool left, Vector& hln, Color eq_color, + bool LineDiff(bool left, Vector& hln, Color eq_color, const wchar *s1, int l1, int h1, const wchar *s2, int l2, int h2, int depth);