OSDN Git Service

Fix #1056: Please add a huge icon for "Filter is active"
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Thu, 25 Nov 2021 14:30:09 +0000 (23:30 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Thu, 25 Nov 2021 14:30:09 +0000 (23:30 +0900)
Src/MergeDoc.cpp
Src/MergeFrameCommon.cpp
Src/MergeFrameCommon.h

index dcf542e..5c69554 100644 (file)
@@ -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<strdiff::wdiff> 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);
 }
 
 /**
index 999f0aa..7714c02 100644 (file)
@@ -147,7 +147,7 @@ void CMergeFrameCommon::ShowIdenticalMessage(const PathContext& paths, bool bIde
 }\r
 \r
 String CMergeFrameCommon::GetTitleString(const PathContext& paths, const String desc[],\r
-       PackingInfo *pInfoUnpacker, PrediffingInfo *pInfoPrediffer)\r
+       PackingInfo *pInfoUnpacker, PrediffingInfo *pInfoPrediffer, bool hasTrivialDiffs)\r
 {\r
        const int nBuffers = paths.GetSize();\r
        String sFileName[3];\r
@@ -158,12 +158,14 @@ String CMergeFrameCommon::GetTitleString(const PathContext& paths, const String
                sTitle = sFileName[0] + strutils::format(_T(" x %d"), nBuffers);\r
        else\r
                sTitle = strutils::join(&sFileName[0], &sFileName[0] + nBuffers, _T(" - "));\r
-       String plugin;\r
+       String flags;\r
        if (pInfoUnpacker && !pInfoUnpacker->GetPluginPipeline().empty())\r
-               plugin += _T("U");\r
+               flags += _T("U");\r
        if (pInfoPrediffer && !pInfoPrediffer->GetPluginPipeline().empty())\r
-               plugin += _T("P");\r
-       return sTitle + (plugin.empty() ? _T("") : (_T(" (") + plugin + _T(")")));\r
+               flags += _T("P");\r
+       if (hasTrivialDiffs)\r
+               flags += _T("F");\r
+       return sTitle + (flags.empty() ? _T("") : (_T(" (") + flags + _T(")")));\r
 }\r
 \r
 void CMergeFrameCommon::OnGetMinMaxInfo(MINMAXINFO* lpMMI)\r
index e2f00fb..65e5c54 100644 (file)
@@ -21,7 +21,7 @@ public:
        void ActivateFrame(int nCmdShow);\r
        void SetLastCompareResult(int nResult);\r
        static void ShowIdenticalMessage(const PathContext& paths, bool bIdenticalAll, std::function<int (LPCTSTR, UINT, UINT)> funcMessageBox);\r
-       static String GetTitleString(const PathContext& paths, const String desc[], PackingInfo *pInfoUnpacker, PrediffingInfo *pInfoPrediffer);\r
+       static String GetTitleString(const PathContext& paths, const String desc[], PackingInfo *pInfoUnpacker, PrediffingInfo *pInfoPrediffer, bool hasTrivialDiffs = false);\r
        void SaveWindowState();\r
        void SetSharedMenu(HMENU hMenu) { m_hMenuShared = hMenu; }\r
        void RemoveBarBorder();\r