Skip to content

Commit

Permalink
Fix issue #940: Replace slow (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdottaka committed Aug 28, 2021
1 parent fed6672 commit 7a7050e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Externals/crystaledit/editlib/ccrystaltextbuffer.cpp
Original file line number Diff line number Diff line change
@@ -1449,6 +1449,14 @@ Undo (CCrystalTextView * pSource, CPoint & ptCursorPos)
bool failed = false;
int tmpPos = m_nUndoPosition;

// Hide caret to quickly undo changes made by Replace All operation
bool bCursorHiddenSaved = false;
if (pSource)
{
bCursorHiddenSaved = pSource->m_bCursorHidden;
pSource->m_bCursorHidden = true;
}

while (!failed)
{
--tmpPos;
@@ -1501,6 +1509,13 @@ Undo (CCrystalTextView * pSource, CPoint & ptCursorPos)
{
m_nUndoPosition = tmpPos;
}

if (pSource)
{
pSource->m_bCursorHidden = bCursorHiddenSaved;
pSource->UpdateCaret();
}

return !failed;
}

@@ -1511,6 +1526,14 @@ Redo (CCrystalTextView * pSource, CPoint & ptCursorPos)
ASSERT ((m_aUndoBuf[0].m_dwFlags & UNDO_BEGINGROUP) != 0);
ASSERT ((m_aUndoBuf[m_nUndoPosition].m_dwFlags & UNDO_BEGINGROUP) != 0);

// Hide caret to quickly redo changes made by Replace All operation
bool bCursorHiddenSaved = false;
if (pSource)
{
bCursorHiddenSaved = pSource->m_bCursorHidden;
pSource->m_bCursorHidden = true;
}

for (;;)
{
const UndoRecord ur = GetUndoRecord(m_nUndoPosition);
@@ -1550,6 +1573,13 @@ Redo (CCrystalTextView * pSource, CPoint & ptCursorPos)
SetModified (false);
if (!m_bModified && m_nSyncPosition != m_nUndoPosition)
SetModified (true);

if (pSource)
{
pSource->m_bCursorHidden = bCursorHiddenSaved;
pSource->UpdateCaret();
}

return true;
}

0 comments on commit 7a7050e

Please sign in to comment.