From 1a0267de7b17c7641ba3b372543b850227b58c0d Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Mon, 14 Mar 2022 23:55:02 +0800 Subject: [PATCH] - fix: when no selection, copy/cut should auto select whole line with the line break --- NEWS.md | 1 + RedPandaIDE/qsynedit/SynEdit.cpp | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/NEWS.md b/NEWS.md index 780f51ba..0eee228b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,6 +13,7 @@ Red Panda C++ Version 1.0.0 - fix: wrong selection when drag & dropped in editor - 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 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 e83a4075..aa8ac192 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -2108,7 +2108,10 @@ void SynEdit::doDeleteLine() void SynEdit::doSelecteLine() { setBlockBegin(BufferCoord{1,mCaretY}); - setBlockEnd(BufferCoord{lineText().length()+1,mCaretY}); + if (mCaretY==mLines->count()) + setBlockEnd(BufferCoord{lineText().length()+1,mCaretY}); + else + setBlockEnd(BufferCoord{1,mCaretY+1}); } void SynEdit::doDuplicateLine() @@ -2817,8 +2820,6 @@ void SynEdit::doCutToClipboard() return; if (!selAvail()) doSelecteLine(); - if (!selAvail()) - return; mUndoList->BeginBlock(); auto action = finally([this] { mUndoList->EndBlock(); @@ -2829,11 +2830,9 @@ void SynEdit::doCutToClipboard() void SynEdit::doCopyToClipboard() { - if (!selAvail()) + bool selected=selAvail(); + if (!selected) doSelecteLine(); - if (!selAvail()) { - return; - } bool ChangeTrim = (mActiveSelectionMode == SynSelectionMode::smColumn) && mOptions.testFlag(eoTrimTrailingSpaces); QString sText; @@ -2847,6 +2846,10 @@ void SynEdit::doCopyToClipboard() sText = selText(); } internalDoCopyToClipboard(sText); + if (!selected) { + setBlockBegin(caretXY()); + setBlockEnd(caretXY()); + } } void SynEdit::internalDoCopyToClipboard(const QString &s)