OSDN Git Service

PATCH: [ 2033754 ] Unlimited undo
authorKimmo Varis <kimmov@gmail.com>
Fri, 1 Aug 2008 06:44:00 +0000 (06:44 +0000)
committerKimmo Varis <kimmov@gmail.com>
Fri, 1 Aug 2008 06:44:00 +0000 (06:44 +0000)
Docs/Users/ChangeLog.txt
Src/DiffTextBuffer.cpp
Src/editlib/ccrystaltextbuffer.cpp
Src/editlib/ccrystaltextbuffer.h

index e91b169..98b008a 100644 (file)
@@ -9,6 +9,7 @@ WinMerge 2.11.1.3
   Remove RCLocalizationHelper plugin (#2029457)
   Clarify Supercopier caused hang in release notes (#2030040)
   Improve tree mode in folder compare (#2018836)
+  Unlimited undo (#2033754)
   BugFix: Could change syntax highlight mode when highlighting was
     disabled from options (#2027325)
   BugFix: Editing line filters updated wrong filter (#2025130)
index a77a2f4..fbc1bc3 100644 (file)
@@ -460,7 +460,6 @@ int CDiffTextBuffer::LoadFromFile(LPCTSTR pszFileNameInit,
                m_bInit = TRUE;
                m_bModified = FALSE;
                m_bUndoGroup = m_bUndoBeginGroup = FALSE;
-               m_nUndoBufSize = 1024; // crystaltextbuffer.cpp - UNDO_BUF_SIZE;
                m_nSyncPosition = m_nUndoPosition = 0;
                ASSERT(m_aUndoBuf.GetSize() == 0);
                m_ptLastChange.x = m_ptLastChange.y = -1;
index f6ec530..1d956a9 100644 (file)
@@ -79,8 +79,6 @@ static char THIS_FILE[] = __FILE__;
 #define     CHAR_ALIGN                  16
 #define     ALIGN_BUF_SIZE(size)        ((size) / CHAR_ALIGN) * CHAR_ALIGN + CHAR_ALIGN;
 
-#define     UNDO_BUF_SIZE               1024
-
 const TCHAR crlf[] = _T ("\r\n");
 
 #ifdef _DEBUG
@@ -402,7 +400,6 @@ InitNew (CRLFSTYLE nCrlfStyle /*= CRLF_STYLE_DOS*/ )
   m_nTabSize = 4;
   m_nSyncPosition = m_nUndoPosition = 0;
   m_bUndoGroup = m_bUndoBeginGroup = FALSE;
-  m_nUndoBufSize = UNDO_BUF_SIZE;
   ASSERT (m_aUndoBuf.GetSize () == 0);
   UpdateViews (NULL, NULL, UPDATE_RESET);
   //BEGIN SW
@@ -1605,45 +1602,6 @@ AddUndoRecord (BOOL bInsert, const CPoint & ptStartPos,
       m_aUndoBuf.SetSize (m_nUndoPosition);
     }
 
-  //  If undo buffer size is close to critical, remove the oldest records
-  ASSERT (m_aUndoBuf.GetSize () <= m_nUndoBufSize);
-  nBufSize = (int) m_aUndoBuf.GetSize ();
-  if (nBufSize >= m_nUndoBufSize)
-    {
-      int nIndex = 0;
-      for (;;)
-        {
-          nIndex++;
-          if (nIndex == nBufSize || (m_aUndoBuf[nIndex].m_dwFlags & UNDO_BEGINGROUP) != 0)
-            break;
-        }
-      m_aUndoBuf.RemoveAt (0, nIndex);
-
-//<jtuc 2003-06-28>
-//- Keep m_nSyncPosition in sync.
-//- Ensure first undo record is flagged UNDO_BEGINGROUP since part of the code
-//  relies on this condition.
-      if (m_nSyncPosition >= 0)
-        {
-          m_nSyncPosition -= nIndex;           // çà c'est bien...mais non, test inutile ? Ou Apres !
-        }
-      if (nIndex < nBufSize)
-        {
-          // Not really necessary as long as groups are discarded as a whole.
-          // Just in case some day the loop above should be changed to limit
-          // the number of discarded undo records to some reasonable value...
-          m_aUndoBuf[0].m_dwFlags |= UNDO_BEGINGROUP;          // çà c'est sale
-        }
-      else
-        {
-          // No undo records left - begin a new group:
-          m_bUndoBeginGroup = TRUE;
-        }
-//</jtuc>
-
-    }
-  ASSERT (m_aUndoBuf.GetSize () < m_nUndoBufSize);
-
   //  Add new record
   SUndoRecord ur;
   ur.m_dwFlags = bInsert ? UNDO_INSERT : 0;
@@ -1660,8 +1618,6 @@ AddUndoRecord (BOOL bInsert, const CPoint & ptStartPos,
 
   m_aUndoBuf.Add (ur);
   m_nUndoPosition = (int) m_aUndoBuf.GetSize ();
-
-  ASSERT (m_aUndoBuf.GetSize () <= m_nUndoBufSize);
 }
 
 LPCTSTR CCrystalTextBuffer::GetStringEol(CRLFSTYLE nCRLFMode)
index 080ff81..19dce60 100644 (file)
@@ -118,7 +118,6 @@ protected :
     CRLFSTYLE m_nCRLFMode;
     BOOL m_IgnoreEol;
     BOOL m_bCreateBackupFile;
-    int m_nUndoBufSize;
     BOOL m_bInsertTabs;
     int  m_nTabSize;
     int FindLineWithFlag (DWORD dwFlag);