From 5a338ef89205fe20111cfb67a9bc503d90117688 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 15 Mar 2022 00:15:35 +0800 Subject: [PATCH] - fix: correctly reset caret when redo cut with no selection --- NEWS.md | 2 ++ RedPandaIDE/qsynedit/SynEdit.cpp | 23 +++++++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/NEWS.md b/NEWS.md index 0eee228b..ec639739 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,6 +14,8 @@ Red Panda C++ Version 1.0.0 - enhancement: toggle block comment - fix: syntax color of #include header filenames not correct - fix: when no selection, copy/cut should auto select whole line with the line break + - fix: redo cut with no selection while make whole line selected + - fix: correctly reset caret when redo cut with no selection Red Panda C++ Version 0.14.5 - fix: the "gnu c++ 20" option in compiler set options is wrong diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index aa8ac192..822d38ee 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -2818,14 +2818,33 @@ void SynEdit::doCutToClipboard() { if (mReadOnly) return; - if (!selAvail()) - doSelecteLine(); mUndoList->BeginBlock(); + if (!selAvail()) { + mUndoList->AddChange( + SynChangeReason::crSelection, + caretXY(), + caretXY(), + "", + SynSelectionMode::smNormal); + mUndoList->AddChange( + SynChangeReason::crCaret, + caretXY(), + caretXY(), + "", + activeSelectionMode()); + doSelecteLine(); + } auto action = finally([this] { mUndoList->EndBlock(); }); internalDoCopyToClipboard(selText()); doSetSelText(""); + mUndoList->AddChange( + SynChangeReason::crNothing, + BufferCoord{0,0}, + BufferCoord{0,0}, + "", + SynSelectionMode::smNormal); } void SynEdit::doCopyToClipboard()