mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-04 15:26:00 +02:00
Fixed undo text corruption bug
This commit is contained in:
parent
1625d511be
commit
6a5b0b49ed
3 changed files with 68 additions and 6 deletions
|
@ -75,6 +75,11 @@ namespace Beefy.utils
|
|||
{
|
||||
return Math.Min(mBatchSize, 256); // Don't allow a large batch (ie: rename) to cause us to pull too much out of the undo buffer
|
||||
}
|
||||
|
||||
public override void ToString(String strBuffer)
|
||||
{
|
||||
strBuffer.AppendF($"UndoBatchStart {mName}");
|
||||
}
|
||||
}
|
||||
|
||||
public class UndoBatchEnd : UndoAction, IUndoBatchEnd
|
||||
|
@ -95,6 +100,11 @@ namespace Beefy.utils
|
|||
return mBatchStart;
|
||||
}
|
||||
}
|
||||
|
||||
public override void ToString(String strBuffer)
|
||||
{
|
||||
strBuffer.AppendF($"UndoBatchEnd {Name}");
|
||||
}
|
||||
}
|
||||
|
||||
public class UndoManager
|
||||
|
@ -307,5 +317,21 @@ namespace Beefy.utils
|
|||
{
|
||||
return mUndoIdx;
|
||||
}
|
||||
|
||||
public override void ToString(String str)
|
||||
{
|
||||
for (int i < mUndoList.Count)
|
||||
{
|
||||
if (i == mUndoIdx)
|
||||
str.Append(">");
|
||||
else
|
||||
str.Append(" ");
|
||||
|
||||
var entry = mUndoList[i];
|
||||
str.AppendF($"{i}. {entry}");
|
||||
|
||||
str.Append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -321,6 +321,14 @@ namespace Beefy.widgets
|
|||
InsertTextAction insertTextAction = nextAction as InsertTextAction;
|
||||
if (insertTextAction == null)
|
||||
return false;
|
||||
|
||||
int curIdx = mCursorTextPos;
|
||||
int nextIdx = insertTextAction.mCursorTextPos;
|
||||
if ((nextIdx != curIdx + mText.Length) ||
|
||||
(mText.EndsWith("\n")) ||
|
||||
(insertTextAction.mText == "\n"))
|
||||
return false;
|
||||
|
||||
if (insertTextAction.mSelection != null)
|
||||
{
|
||||
if (mSelection == null)
|
||||
|
@ -335,14 +343,9 @@ namespace Beefy.widgets
|
|||
mSelectionText.Append(insertTextAction.mSelectionText);
|
||||
}
|
||||
|
||||
int curIdx = mCursorTextPos;
|
||||
int nextIdx = insertTextAction.mCursorTextPos;
|
||||
mRestoreSelectionOnUndo &= insertTextAction.mRestoreSelectionOnUndo;
|
||||
|
||||
if ((nextIdx != curIdx + mText.Length) ||
|
||||
(mText.EndsWith("\n")) ||
|
||||
(insertTextAction.mText == "\n"))
|
||||
return false;
|
||||
|
||||
|
||||
mText.Append(insertTextAction.mText);
|
||||
return true;
|
||||
|
@ -374,6 +377,31 @@ namespace Beefy.widgets
|
|||
editWidgetContent.mEditWidget.FinishScroll();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void ToString(String strBuffer)
|
||||
{
|
||||
strBuffer.Append("InsertTextAction");
|
||||
if (mText != null)
|
||||
{
|
||||
strBuffer.Append(" ");
|
||||
mText.Quote(strBuffer);
|
||||
}
|
||||
|
||||
strBuffer.AppendF($" CursorTextPos:{mCursorTextPos}");
|
||||
strBuffer.AppendF(" Selection:");
|
||||
if (mSelection != null)
|
||||
{
|
||||
strBuffer.AppendF($"{mSelection.Value.mStartPos}-{mSelection.Value.mEndPos}");
|
||||
}
|
||||
else
|
||||
strBuffer.AppendF("null");
|
||||
|
||||
if (mSelectionText != null)
|
||||
{
|
||||
strBuffer.AppendF(" SelectionText:");
|
||||
mSelectionText.Quote(strBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class DeleteCharAction : TextAction
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue