- fix: selection is not correctly set after input in column mode

This commit is contained in:
Roy Qu 2022-07-25 14:32:12 +08:00
parent 7db3a7ebc1
commit 62caa94e23
2 changed files with 17 additions and 22 deletions

View File

@ -1,6 +1,7 @@
Red Panda C++ Version 1.1.6 Red Panda C++ Version 1.1.6
- fix: block indent doesn't work - fix: block indent doesn't work
- fix: selection is not correctly set after input in column mode
Red Panda C++ Version 1.1.5 Red Panda C++ Version 1.1.5

View File

@ -2541,25 +2541,20 @@ void SynEdit::doTabKey()
doBlockIndent(); doBlockIndent();
return; return;
} }
int i = 0; mUndoList->beginBlock();
{ if (selAvail()) {
mUndoList->beginBlock(); setSelectedTextEmpty();
auto action = finally([this]{
mUndoList->endBlock();
});
if (selAvail()) {
setSelectedTextEmpty();
}
QString Spaces;
if (mOptions.testFlag(eoTabsToSpaces)) {
int cols = charToColumn(mCaretY,mCaretX);
i = tabWidth() - (cols) % tabWidth();
Spaces = QString(i,' ');
} else {
Spaces = '\t';
}
setSelTextPrimitive(QStringList(Spaces));
} }
QString Spaces;
if (mOptions.testFlag(eoTabsToSpaces)) {
int cols = charToColumn(mCaretY,mCaretX);
int i = tabWidth() - (cols) % tabWidth();
Spaces = QString(i,' ');
} else {
Spaces = '\t';
}
setSelTextPrimitive(QStringList(Spaces));
mUndoList->endBlock();
ensureCursorPosVisible(); ensureCursorPosVisible();
} }
@ -6634,10 +6629,9 @@ void SynEdit::onLinesChanged()
if (mActiveSelectionMode == SynSelectionMode::Column) { if (mActiveSelectionMode == SynSelectionMode::Column) {
BufferCoord oldBlockStart = blockBegin(); BufferCoord oldBlockStart = blockBegin();
BufferCoord oldBlockEnd = blockEnd(); BufferCoord oldBlockEnd = blockEnd();
oldBlockStart.ch = mCaretX; int colEnd = charToColumn(mCaretY,mCaretX);
int colEnd = charToColumn(oldBlockStart.line,oldBlockStart.ch); oldBlockStart.ch = columnToChar(oldBlockStart.line,colEnd);
int charEnd = columnToChar(oldBlockEnd.line,colEnd); oldBlockEnd.ch = columnToChar(oldBlockEnd.line,colEnd);
oldBlockEnd.ch = charEnd;
setBlockBegin(oldBlockStart); setBlockBegin(oldBlockStart);
setBlockEnd(oldBlockEnd); setBlockEnd(oldBlockEnd);
} else { } else {