OSDN Git Service

PATCH: [ 1467872 ] Fix diff navigation for first-line of diff
authorKimmo Varis <kimmov@gmail.com>
Tue, 11 Apr 2006 15:57:46 +0000 (15:57 +0000)
committerKimmo Varis <kimmov@gmail.com>
Tue, 11 Apr 2006 15:57:46 +0000 (15:57 +0000)
Src/Changes.txt
Src/MergeEditView.cpp

index 74361a9..b9e18f8 100644 (file)
@@ -2,6 +2,10 @@ Src\Changes.txt
 Add new items to top.
 (This summarizes all changes to all files under Src, including Src\Languages.)
 
+2006-04-11 Kimmo
+ PATCH: [ 1467872 ] Fix diff navigation for first-line of diff
+  Src: MergeEditView.cpp
+
 2006-04-10 Kimmo
  PATCH: [ 1467305 ] Beep when long compare is ready
   Src: DirView.cpp DirView.h
index 6b39674..6d6a85f 100644 (file)
@@ -884,23 +884,29 @@ void CMergeEditView::OnNextdiff()
                {
                        // Selected difference not visible, select next from cursor
                        int line = GetCursorPos().y;
+                       // Make sure we aren't in the first line of the diff
+                       ++line;
                        if (!IsValidTextPosY(CPoint(0, line)))
                                line = m_nTopLine;
                        nextDiff = pd->m_diffList.NextSignificantDiffFromLine(line);
                }
-               // Find out if there is a following significant diff
-               else if (curDiff < pd->m_diffList.GetSize() - 1)
+               else
                {
-                       nextDiff = pd->m_diffList.NextSignificantDiff(curDiff);
-                       if (nextDiff == -1)
-                               nextDiff = curDiff;
+                       // Find out if there is a following significant diff
+                       if (curDiff < pd->m_diffList.GetSize() - 1)
+                       {
+                               nextDiff = pd->m_diffList.NextSignificantDiff(curDiff);
+                               if (nextDiff == -1)
+                                       nextDiff = curDiff;
+                       }
                }
                // nextDiff is the next one if there is one, else it is the one we're on
                SelectDiff(nextDiff, TRUE, FALSE);
        }
        else
        {
-               // we're not on a diff, so figure out which one to select
+               // We don't have a selected difference,
+               // but cursor can be inside inactive diff
                int line = GetCursorPos().y;
                if (!IsValidTextPosY(CPoint(0, line)))
                        line = m_nTopLine;
@@ -961,23 +967,29 @@ void CMergeEditView::OnPrevdiff()
                {
                        // Selected difference not visible, select previous from cursor
                        int line = GetCursorPos().y;
+                       // Make sure we aren't in the last line of the diff
+                       --line;
                        if (!IsValidTextPosY(CPoint(0, line)))
                                line = m_nTopLine;
                        prevDiff = pd->m_diffList.PrevSignificantDiffFromLine(line);
                }
-               // Find out if there is a preceding significant diff
-               if (curDiff > 0)
+               else
                {
-                       prevDiff = pd->m_diffList.PrevSignificantDiff(curDiff);
-                       if (prevDiff == -1)
-                               prevDiff = curDiff;
+                       // Find out if there is a preceding significant diff
+                       if (curDiff > 0)
+                       {
+                               prevDiff = pd->m_diffList.PrevSignificantDiff(curDiff);
+                               if (prevDiff == -1)
+                                       prevDiff = curDiff;
+                       }
                }
                // prevDiff is the preceding one if there is one, else it is the one we're on
                SelectDiff(prevDiff, TRUE, FALSE);
        }
        else
        {
-               // we're not on a diff, so figure out which one to select
+               // We don't have a selected difference,
+               // but cursor can be inside inactive diff
                int line = GetCursorPos().y;
                if (!IsValidTextPosY(CPoint(0, line)))
                        line = m_nTopLine;