From f412eedcb0a1d18aa514c515c297b22438e3e5ca Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sat, 14 May 2022 16:06:57 +0800 Subject: [PATCH] - fix: selection calculation error when editing in column mode --- NEWS.md | 1 + RedPandaIDE/qsynedit/SynEdit.cpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 85235333..b955de0e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,7 @@ Red Panda C++ Version 1.0.8 - enhancement: auto complete '#undef' - enhancement: redesign components for compiler commandline arguments processing + - fix: selection calculation error when editing in column mode Red Panda C++ Version 1.0.7 - change: use Shift+Enter to break line diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 6aaad345..f408a50e 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -6625,12 +6625,18 @@ void SynEdit::setActiveSelectionMode(const SynSelectionMode &Value) BufferCoord SynEdit::blockEnd() const { + if (mActiveSelectionMode == SynSelectionMode::smColumn) { + return BufferCoord{ + std::max(mBlockBegin.Char,mBlockEnd.Char), + std::max(mBlockBegin.Line,mBlockEnd.Line), + }; + } + if ((mBlockEnd.Line < mBlockBegin.Line) || ((mBlockEnd.Line == mBlockBegin.Line) && (mBlockEnd.Char < mBlockBegin.Char))) return mBlockBegin; else return mBlockEnd; - } void SynEdit::setBlockEnd(BufferCoord Value) @@ -6717,6 +6723,12 @@ void SynEdit::setSelText(const QString &text) BufferCoord SynEdit::blockBegin() const { + if (mActiveSelectionMode == SynSelectionMode::smColumn) { + return BufferCoord{ + std::min(mBlockBegin.Char,mBlockEnd.Char), + std::min(mBlockBegin.Line,mBlockEnd.Line), + }; + } if ((mBlockEnd.Line < mBlockBegin.Line) || ((mBlockEnd.Line == mBlockBegin.Line) && (mBlockEnd.Char < mBlockBegin.Char))) return mBlockEnd;