OSDN Git Service

Fix GitHub issue #362: opening same file
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 14 Jun 2020 06:34:17 +0000 (15:34 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Sun, 14 Jun 2020 06:34:17 +0000 (15:34 +0900)
Src/MergeDoc.cpp

index 10c0234..0493649 100644 (file)
@@ -731,14 +731,7 @@ void CMergeDoc::ShowRescanError(int nRescanResult, IDENTLEVEL identical)
        // Files are not binaries, but they are identical
        if (identical != IDENTLEVEL_NONE)
        {
-               if (!m_filePaths.GetLeft().empty() && !m_filePaths.GetMiddle().empty() && !m_filePaths.GetRight().empty() && 
-                       m_filePaths.GetLeft() == m_filePaths.GetRight() && m_filePaths.GetMiddle() == m_filePaths.GetRight())
-               {
-                       // compare file to itself, a custom message so user may hide the message in this case only
-                       s = _("The same file is opened in both panels.");
-                       ShowMessageBox(s, MB_ICONINFORMATION | MB_DONT_DISPLAY_AGAIN, IDS_FILE_TO_ITSELF);
-               }
-               else if (identical == IDENTLEVEL_ALL)
+               if (theApp.m_bExitIfNoDiff != MergeCmdLineInfo::ExitQuiet)
                {
                        UINT nFlags = MB_ICONINFORMATION | MB_DONT_DISPLAY_AGAIN;
 
@@ -749,13 +742,26 @@ void CMergeDoc::ShowRescanError(int nRescanResult, IDENTLEVEL identical)
                                // of the "exit no diff".
                                nFlags &= ~MB_DONT_DISPLAY_AGAIN;
                        }
-
-                       if (theApp.m_bExitIfNoDiff != MergeCmdLineInfo::ExitQuiet)
+                       if ((m_nBuffers == 2 && !m_filePaths.GetLeft().empty() && !m_filePaths.GetRight().empty() &&
+                                strutils::compare_nocase(m_filePaths.GetLeft(), m_filePaths.GetRight())) == 0 ||
+                               (m_nBuffers == 3 && !m_filePaths.GetLeft().empty() && !m_filePaths.GetMiddle().empty() && !m_filePaths.GetRight().empty() &&
+                                strutils::compare_nocase(m_filePaths.GetLeft(), m_filePaths.GetRight()) == 0 ||
+                                strutils::compare_nocase(m_filePaths.GetMiddle(), m_filePaths.GetRight()) == 0 ||
+                                strutils::compare_nocase(m_filePaths.GetLeft(), m_filePaths.GetMiddle()) == 0))
+                       {
+                               // compare file to itself, a custom message so user may hide the message in this case only
+                               s = _("The same file is opened in both panels.");
+                               ShowMessageBox(s, nFlags, IDS_FILE_TO_ITSELF);
+                       }
+                       else if (identical == IDENTLEVEL_ALL)
                        {
                                s = _("The selected files are identical.");
                                ShowMessageBox(s, nFlags, IDS_FILESSAME);
                        }
+               }
 
+               if (identical == IDENTLEVEL_ALL)
+               {
                        // Exit application if files are identical.
                        if (theApp.m_bExitIfNoDiff == MergeCmdLineInfo::Exit ||
                                theApp.m_bExitIfNoDiff == MergeCmdLineInfo::ExitQuiet)