Skip to content

Commit 0ecf628

Browse files
committed
WIP (41)
1 parent 5b330f4 commit 0ecf628

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/WinWebDiffLib/DiffHighlighter.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -706,8 +706,6 @@ class Highlighter
706706
className += deleted ? L" wwd-deleted" : L" wwd-changed";
707707
auto& allocator = m_documents[pane].GetAllocator();
708708
std::wstring orgtext;
709-
if (diffInfo.nodePos[pane] == 0)
710-
orgtext = textBlocks[pane].textBlocks;
711709
if (diffInfo.nodePos[pane] == 0)
712710
{
713711
if (diffInfo.nodeTypes[pane] == 1 /* ELEMENT_NODE */)
@@ -719,7 +717,7 @@ class Highlighter
719717
{
720718
WValue spanNode, attributes, children;
721719
attributes.SetArray();
722-
appendAttributes(attributes, className, i, orgtext, allocator);
720+
appendAttributes(attributes, className, i, textBlocks[pane].textBlocks, allocator);
723721
spanNode.SetObject();
724722
spanNode.AddMember(L"nodeName", L"SPAN", allocator);
725723
spanNode.AddMember(L"attributes", attributes, allocator);
@@ -748,7 +746,7 @@ class Highlighter
748746
{
749747
WValue spanNode, attributes, children;
750748
attributes.SetArray();
751-
appendAttributes(attributes, className, i, orgtext, allocator);
749+
appendAttributes(attributes, className, i, L"", allocator);
752750
spanNode.SetObject();
753751
spanNode.AddMember(L"nodeName", L"SPAN", allocator);
754752
spanNode.AddMember(L"attributes", attributes, allocator);
@@ -1151,8 +1149,8 @@ class Highlighter
11511149
const auto& ary = value[L"attributes"].GetArray();
11521150
for (unsigned int i = 0; i + 1 < ary.Size(); i += 2)
11531151
{
1154-
if (wcscmp(ary[i].GetString(), L"class") == 0 ||
1155-
wcsstr(ary[i].GetString(), name) != nullptr)
1152+
if (wcscmp(ary[i].GetString(), L"class") == 0 &&
1153+
wcsstr(ary[i + 1].GetString(), name) != nullptr)
11561154
return true;
11571155
}
11581156
return false;

src/WinWebDiffLib/WebDiffWindow.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,16 @@ LR"(
740740
{
741741
Highlighter highlighter(*documents.get(), m_diffInfos, m_colorSettings, m_diffOptions, m_bShowWordDifferences, m_currentDiffIndex);
742742
highlighter.highlightNodes();
743+
#ifdef _DEBUG
744+
for (int pane = 0; pane < m_nPanes; ++pane)
745+
{
746+
WStringBuffer buffer;
747+
WPrettyWriter writer(buffer);
748+
(*documents)[pane].Accept(writer);
749+
WriteToTextFile((L"c:\\tmp\\file" + std::to_wstring(pane) + L"_1.json"),
750+
buffer.GetString());
751+
}
752+
#endif
743753
}
744754
hr = highlightDocuments(documents,
745755
Callback<IWebDiffCallback>([this, callback2](const WebDiffCallbackResult& result) -> HRESULT
@@ -936,6 +946,14 @@ LR"(
936946
{
937947
WDocument doc;
938948
doc.Parse(result.returnObjectAsJson);
949+
#ifdef _DEBUG
950+
WStringBuffer buffer;
951+
WPrettyWriter writer(buffer);
952+
doc.Accept(writer);
953+
WriteToTextFile((L"c:\\tmp\\file" + std::to_wstring(pane) + L"_2.json"),
954+
buffer.GetString());
955+
#endif
956+
939957
std::map<int, int> nodes;
940958
Highlighter::getDiffNodes(doc[L"root"], nodes);
941959
for (unsigned i = 0; i < m_diffInfos.size(); ++i)

0 commit comments

Comments
 (0)