Skip to content

Commit 992ac65

Browse files
committed
Fix word-by-word differences where one of the words has been deleted to be highlighted in the color for deletion.
1 parent 54e857c commit 992ac65

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/WinWebDiffLib/DiffHighlighter.hpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -991,14 +991,16 @@ class Highlighter
991991
styles += L" .wwd-deleted { " + getDiffStyleValue(colorSettings.clrDiffText, colorSettings.clrDiffDeleted) + L" }\n";
992992
styles += L" .wwd-snpchanged { " + getDiffStyleValue(colorSettings.clrSNPText, colorSettings.clrSNP) + L" }\n";
993993
styles += L" .wwd-snpdeleted { " + getDiffStyleValue(colorSettings.clrSNPText, colorSettings.clrSNPDeleted) + L" }\n";
994-
styles += L" .wwd-word { " + getDiffStyleValue(colorSettings.clrWordDiffText, colorSettings.clrWordDiff) + L" }\n";
994+
styles += L" .wwd-wordchanged { " + getDiffStyleValue(colorSettings.clrWordDiffText, colorSettings.clrWordDiff) + L" }\n";
995+
styles += L" .wwd-worddeleted { " + getDiffStyleValue(colorSettings.clrWordDiffText, colorSettings.clrWordDiffDeleted) + L" }\n";
995996

996997
std::wstring datawwdid = L"[data-wwdid=\"" + std::to_wstring(diffIndex) + L"\"]";
997998
styles += L" .wwd-changed" + datawwdid + L" { " + getDiffStyleValue(colorSettings.clrSelDiffText, colorSettings.clrSelDiff) + L" }\n";
998999
styles += L" .wwd-deleted" + datawwdid + L" { " + getDiffStyleValue(colorSettings.clrSelDiffText, colorSettings.clrSelDiffDeleted) + L" }\n";
9991000
styles += L" .wwd-snpchanged" + datawwdid + L" { " + getDiffStyleValue(colorSettings.clrSelSNPText, colorSettings.clrSelSNP) + L" }\n";
10001001
styles += L" .wwd-snpdeleted" + datawwdid + L" { " + getDiffStyleValue(colorSettings.clrSelSNPText, colorSettings.clrSelSNPDeleted) + L" }\n";
1001-
styles += L" .wwd-diff" + datawwdid + L" .wwd-word { " + getDiffStyleValue(colorSettings.clrSelWordDiffText, colorSettings.clrSelWordDiff) + L" }\n";
1002+
styles += L" .wwd-diff" + datawwdid + L" .wwd-wordchanged { " + getDiffStyleValue(colorSettings.clrSelWordDiffText, colorSettings.clrSelWordDiff) + L" }\n";
1003+
styles += L" .wwd-diff" + datawwdid + L" .wwd-worddeleted { " + getDiffStyleValue(colorSettings.clrSelWordDiffText, colorSettings.clrSelWordDiffDeleted) + L" }\n";
10021004
return styles;
10031005
}
10041006

@@ -1137,6 +1139,10 @@ class Highlighter
11371139
size_t begin = 0;
11381140
for (const auto& diffInfo: wordDiffInfoList)
11391141
{
1142+
bool deleted = false;
1143+
for (size_t pane = 0; pane < m_documents.size(); ++pane)
1144+
if (diffInfo.end[pane] < diffInfo.begin[pane])
1145+
deleted = true;
11401146
auto it = textSegments.segments.begin();
11411147
std::advance(it, diffInfo.begin[pane]);
11421148
if (it != textSegments.segments.end())
@@ -1162,7 +1168,7 @@ class Highlighter
11621168

11631169
if (!textDiff.empty())
11641170
{
1165-
std::wstring className = L"wwd-wdiff wwd-word";
1171+
std::wstring className = deleted ? L"wwd-wdiff wwd-worddeleted" : L"wwd-wdiff wwd-wordchanged";
11661172
WValue spanNode, diffTextNode, attributes, spanChildren;
11671173
WValue textDiffValue(textDiff.c_str(), static_cast<unsigned>(textDiff.size()), allocator);
11681174
WValue classNameValue(className.c_str(), static_cast<unsigned>(className.size()), allocator);

0 commit comments

Comments
 (0)