From 3c84e8b5936562e7b87e9376dcaa3f32afbeb3be Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Thu, 25 Nov 2021 23:30:09 +0900 Subject: [PATCH] Fix #1056: Please add a huge icon for "Filter is active" --- Src/MergeDoc.cpp | 24 +++++++++++++++--------- Src/MergeFrameCommon.cpp | 12 +++++++----- Src/MergeFrameCommon.h | 2 +- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Src/MergeDoc.cpp b/Src/MergeDoc.cpp index dcf542e86..5c69554e6 100644 --- a/Src/MergeDoc.cpp +++ b/Src/MergeDoc.cpp @@ -642,7 +642,7 @@ void CMergeDoc::FlagTrivialLines(void) for (int file = 0; file < m_nBuffers; ++file) { const TCHAR *p = m_ptBuf[file]->GetLineChars(i); - str[file] = p ? p : _T(""); + str[file] = p ? String(p, m_ptBuf[file]->GetFullLineLength(i)) : _T(""); } if (std::count(str + 1, str + m_nBuffers, str[0]) != m_nBuffers - 1) @@ -651,17 +651,24 @@ void CMergeDoc::FlagTrivialLines(void) m_diffWrapper.GetOptions(&diffOptions); // Make the call to stringdiffs, which does all the hard & tedious computations - std::vector worddiffs = strdiff::ComputeWordDiffs(m_nBuffers, str, + int result = strdiff::Compare(str[0], str[1], !diffOptions.bIgnoreCase, !diffOptions.bIgnoreEol, diffOptions.nIgnoreWhitespace, - diffOptions.bIgnoreNumbers, - GetBreakType(), // whitespace only or include punctuation - GetByteColoringOption()); - if (!worddiffs.empty()) + diffOptions.bIgnoreNumbers); + if (m_nBuffers >= 2 && result == 0) + { + result = strdiff::Compare(str[1], str[2], + !diffOptions.bIgnoreCase, + !diffOptions.bIgnoreEol, + diffOptions.nIgnoreWhitespace, + diffOptions.bIgnoreNumbers); + } + if (result != 0) { for (int file = 0; file < m_nBuffers; ++file) m_ptBuf[file]->SetLineFlag(i, LF_TRIVIAL, true, false, false); + ++m_nTrivialDiffs; } } } @@ -1968,6 +1975,7 @@ void CMergeDoc::FlushAndRescan(bool bForced /* =false */) if (nRescanResult != RESCAN_SUPPRESSED) ShowRescanError(nRescanResult, identical); m_LastRescan = COleDateTime::GetCurrentTime(); + SetTitle(nullptr); } /** @@ -3482,7 +3490,7 @@ void CMergeDoc::SetTitle(LPCTSTR lpszTitle) { PrediffingInfo infoPrediffer; GetPrediffer(&infoPrediffer); - String sTitle = (lpszTitle != nullptr) ? lpszTitle : CMergeFrameCommon::GetTitleString(m_filePaths, m_strDesc, &m_infoUnpacker, &infoPrediffer); + String sTitle = (lpszTitle != nullptr) ? lpszTitle : CMergeFrameCommon::GetTitleString(m_filePaths, m_strDesc, &m_infoUnpacker, &infoPrediffer, m_nTrivialDiffs > 0); CDocument::SetTitle(sTitle.c_str()); } @@ -3638,7 +3646,6 @@ void CMergeDoc::OnApplyPrediffer() SetPrediffer(&prediffer); m_CurrentPredifferID = -1; FlushAndRescan(true); - SetTitle(nullptr); } /** @@ -3744,7 +3751,6 @@ void CMergeDoc::OnPrediffer(UINT nID ) { SetPredifferByMenu(nID); FlushAndRescan(true); - SetTitle(nullptr); } /** diff --git a/Src/MergeFrameCommon.cpp b/Src/MergeFrameCommon.cpp index 999f0aa5d..7714c0251 100644 --- a/Src/MergeFrameCommon.cpp +++ b/Src/MergeFrameCommon.cpp @@ -147,7 +147,7 @@ void CMergeFrameCommon::ShowIdenticalMessage(const PathContext& paths, bool bIde } String CMergeFrameCommon::GetTitleString(const PathContext& paths, const String desc[], - PackingInfo *pInfoUnpacker, PrediffingInfo *pInfoPrediffer) + PackingInfo *pInfoUnpacker, PrediffingInfo *pInfoPrediffer, bool hasTrivialDiffs) { const int nBuffers = paths.GetSize(); String sFileName[3]; @@ -158,12 +158,14 @@ String CMergeFrameCommon::GetTitleString(const PathContext& paths, const String sTitle = sFileName[0] + strutils::format(_T(" x %d"), nBuffers); else sTitle = strutils::join(&sFileName[0], &sFileName[0] + nBuffers, _T(" - ")); - String plugin; + String flags; if (pInfoUnpacker && !pInfoUnpacker->GetPluginPipeline().empty()) - plugin += _T("U"); + flags += _T("U"); if (pInfoPrediffer && !pInfoPrediffer->GetPluginPipeline().empty()) - plugin += _T("P"); - return sTitle + (plugin.empty() ? _T("") : (_T(" (") + plugin + _T(")"))); + flags += _T("P"); + if (hasTrivialDiffs) + flags += _T("F"); + return sTitle + (flags.empty() ? _T("") : (_T(" (") + flags + _T(")"))); } void CMergeFrameCommon::OnGetMinMaxInfo(MINMAXINFO* lpMMI) diff --git a/Src/MergeFrameCommon.h b/Src/MergeFrameCommon.h index e2f00fbf7..65e5c5400 100644 --- a/Src/MergeFrameCommon.h +++ b/Src/MergeFrameCommon.h @@ -21,7 +21,7 @@ public: void ActivateFrame(int nCmdShow); void SetLastCompareResult(int nResult); static void ShowIdenticalMessage(const PathContext& paths, bool bIdenticalAll, std::function funcMessageBox); - static String GetTitleString(const PathContext& paths, const String desc[], PackingInfo *pInfoUnpacker, PrediffingInfo *pInfoPrediffer); + static String GetTitleString(const PathContext& paths, const String desc[], PackingInfo *pInfoUnpacker, PrediffingInfo *pInfoPrediffer, bool hasTrivialDiffs = false); void SaveWindowState(); void SetSharedMenu(HMENU hMenu) { m_hMenuShared = hMenu; } void RemoveBarBorder(); -- 2.11.0