mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-14 22:34:09 +02:00
Fixed line paste indent issues
This commit is contained in:
parent
a700a6bbd2
commit
2a57d9d447
2 changed files with 36 additions and 24 deletions
|
@ -2054,6 +2054,8 @@ namespace Beefy.widgets
|
||||||
CursorLineAndColumn = .(origPosition.mLine, 0);
|
CursorLineAndColumn = .(origPosition.mLine, 0);
|
||||||
var lineStartPosition = CursorLineAndColumn;
|
var lineStartPosition = CursorLineAndColumn;
|
||||||
InsertAtCursor("\n");
|
InsertAtCursor("\n");
|
||||||
|
if (var insertTextAction = mData.mUndoManager.GetLastUndoAction() as InsertTextAction)
|
||||||
|
insertTextAction.mVirtualCursorPos = origPosition;
|
||||||
CursorLineAndColumn = lineStartPosition;
|
CursorLineAndColumn = lineStartPosition;
|
||||||
CursorToLineStart(false);
|
CursorToLineStart(false);
|
||||||
|
|
||||||
|
@ -2071,7 +2073,7 @@ namespace Beefy.widgets
|
||||||
}
|
}
|
||||||
|
|
||||||
PasteText(text);
|
PasteText(text);
|
||||||
CursorLineAndColumn = origPosition;
|
CursorLineAndColumn = .(origPosition.mLine + 1, origPosition.mColumn);
|
||||||
mData.mUndoManager.Add(undoBatchStart.mBatchEnd);
|
mData.mUndoManager.Add(undoBatchStart.mBatchEnd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1230,7 +1230,25 @@ namespace IDE.ui
|
||||||
|
|
||||||
var lineAndColumn = CursorLineAndColumn;
|
var lineAndColumn = CursorLineAndColumn;
|
||||||
var lineText = scope String();
|
var lineText = scope String();
|
||||||
|
|
||||||
|
bool startsWithNewline = (forceMatchIndent) && (str.StartsWith("\n"));
|
||||||
|
bool isMultiline = str.Contains("\n");
|
||||||
|
|
||||||
|
if (startsWithNewline || isMultiline)
|
||||||
|
{
|
||||||
|
var undoBatchStart = new UndoBatchStart("pasteText");
|
||||||
|
mData.mUndoManager.Add(undoBatchStart);
|
||||||
|
defer(stack) mData.mUndoManager.Add(undoBatchStart.mBatchEnd);
|
||||||
|
}
|
||||||
|
|
||||||
if (HasSelection())
|
if (HasSelection())
|
||||||
|
{
|
||||||
|
if (isMultiline)
|
||||||
|
{
|
||||||
|
DeleteSelection();
|
||||||
|
lineAndColumn = CursorLineAndColumn;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
int startPos;
|
int startPos;
|
||||||
int endPos;
|
int endPos;
|
||||||
|
@ -1249,19 +1267,11 @@ namespace IDE.ui
|
||||||
|
|
||||||
ExtractString(lineStart, startPos - lineStart, lineText);
|
ExtractString(lineStart, startPos - lineStart, lineText);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
GetLineText(lineAndColumn.mLine, lineText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool startsWithNewline = (forceMatchIndent) && (str.StartsWith("\n"));
|
if (lineText.IsEmpty)
|
||||||
bool isMultiline = str.Contains("\n");
|
|
||||||
|
|
||||||
if (startsWithNewline || isMultiline)
|
|
||||||
{
|
{
|
||||||
var undoBatchStart = new UndoBatchStart("pasteText");
|
GetLineText(lineAndColumn.mLine, lineText);
|
||||||
mData.mUndoManager.Add(undoBatchStart);
|
|
||||||
defer(stack) mData.mUndoManager.Add(undoBatchStart.mBatchEnd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startsWithNewline)
|
if (startsWithNewline)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue