- fix: block indent doesn't work

This commit is contained in:
Roy Qu 2022-07-25 09:45:06 +08:00
parent 1b56f1b615
commit 7db3a7ebc1
6 changed files with 37 additions and 19 deletions

View File

@ -1,3 +1,7 @@
Red Panda C++ Version 1.1.6
- fix: block indent doesn't work
Red Panda C++ Version 1.1.5
- change: uncheck "hide unsupported files" in files view shouldn't gray out non-c files

View File

@ -10,7 +10,7 @@ isEmpty(APP_NAME) {
}
isEmpty(APP_VERSION) {
APP_VERSION=1.1.5
APP_VERSION=1.1.6
}
macos: {

View File

@ -871,7 +871,7 @@
<enum>QTabWidget::South</enum>
</property>
<property name="currentIndex">
<number>2</number>
<number>1</number>
</property>
<property name="iconSize">
<size>

View File

@ -2774,7 +2774,6 @@ void SynEdit::doBlockIndent()
QStringList strToInsert;
int e,x,i;
QString spaces;
BufferCoord insertionPos;
oldCaretPos = caretXY();
@ -2802,19 +2801,41 @@ void SynEdit::doBlockIndent()
} else {
spaces = "\t";
}
for (i = BB.line; i<e;i++) {
strToInsert.append(spaces);
}
strToInsert.append(spaces);
// for (i = BB.line; i<e;i++) {
// strToInsert.append(spaces);
// }
// strToInsert.append(spaces);
mUndoList->beginBlock();
mUndoList->addChange(SynChangeReason::Caret, oldCaretPos, oldCaretPos,QStringList(), activeSelectionMode());
mUndoList->addChange(SynChangeReason::Selection,mBlockBegin,mBlockEnd,QStringList(), activeSelectionMode());
insertionPos.line = BB.line;
int ch;
if (mActiveSelectionMode == SynSelectionMode::Column)
insertionPos.ch = std::min(BB.ch, BE.ch);
ch = std::min(BB.ch, BE.ch);
else
insertionPos.ch = 1;
insertBlock(insertionPos, strToInsert);
ch = 1;
for (i = BB.line; i<=e;i++) {
if (i>mDocument->count())
break;
QString line=mDocument->getString(i-1);
if (ch>line.length()) {
mUndoList->addChange(
SynChangeReason::Insert,
BufferCoord{line.length(), i},
BufferCoord{line.length()+spaces.length(), i},
QStringList(),
SynSelectionMode::Normal);
line+=spaces;
} else {
mUndoList->addChange(
SynChangeReason::Insert,
BufferCoord{ch, i},
BufferCoord{ch+spaces.length(), i},
QStringList(),
SynSelectionMode::Normal);
line = line.left(ch-1)+spaces+line.mid(ch-1);
}
properSetLine(i-1,line);
}
//adjust caret and selection
oldCaretPos.ch = x;
if (BB.ch > 1)
@ -3255,12 +3276,6 @@ void SynEdit::doOnStatusChange(SynStatusChanges)
mStatusChanges = SynStatusChange::scNone;
}
void SynEdit::insertBlock(const BufferCoord& startPos, const QStringList& blockText)
{
setCaretAndSelection(startPos, startPos, startPos);
setSelTextPrimitiveEx(SynSelectionMode::Column, blockText);
}
void SynEdit::updateScrollbars()
{
int nMaxScroll;

View File

@ -509,7 +509,6 @@ private:
void internalSetCaretY(int Value);
void setStatusChanged(SynStatusChanges changes);
void doOnStatusChange(SynStatusChanges changes);
void insertBlock(const BufferCoord& startPos, const QStringList& blockText);
void updateScrollbars();
void updateCaret();
void recalcCharExtent();

View File

@ -23,7 +23,7 @@ SUBDIRS += \
APP_NAME = RedPandaCPP
APP_VERSION = 1.1.5
APP_VERSION = 1.1.6
linux: {
isEmpty(PREFIX) {