- fix: when no selection, copy/cut should auto select whole line with the line break

This commit is contained in:
Roy Qu 2022-03-14 23:55:02 +08:00
parent 0286043cd7
commit 1a0267de7b
2 changed files with 11 additions and 7 deletions

View File

@ -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

View File

@ -2108,7 +2108,10 @@ void SynEdit::doDeleteLine()
void SynEdit::doSelecteLine()
{
setBlockBegin(BufferCoord{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)