fix: wrong indent when paste

This commit is contained in:
Roy Qu 2024-03-05 17:09:43 +08:00
parent e0438b1bf9
commit 417c33a8dc
1 changed files with 6 additions and 5 deletions

View File

@ -3274,8 +3274,6 @@ void QSynEdit::updateModifiedStatus()
void QSynEdit::reparseLines(int startLine, int endLine) void QSynEdit::reparseLines(int startLine, int endLine)
{ {
if (mEditingCount>0)
return;
SyntaxState state; SyntaxState state;
startLine = std::max(0,startLine); startLine = std::max(0,startLine);
@ -3295,8 +3293,11 @@ void QSynEdit::reparseLines(int startLine, int endLine)
mSyntaxer->nextToEol(); mSyntaxer->nextToEol();
state = mSyntaxer->getState(); state = mSyntaxer->getState();
mDocument->setSyntaxState(line,state); mDocument->setSyntaxState(line,state);
line ++ ; line++ ;
} while (line < endLine); } while (line < endLine);
if (mEditingCount>0)
return;
if (useCodeFolding()) if (useCodeFolding())
rescanFolds(); rescanFolds();
return ; return ;
@ -5428,7 +5429,7 @@ int QSynEdit::doInsertTextByNormalMode(const BufferCoord& pos, const QStringList
str = sLeftSide + text[0] + sRightSide; str = sLeftSide + text[0] + sRightSide;
properSetLine(caretY - 1, str); properSetLine(caretY - 1, str);
} }
reparseLines(caretY,caretY+1); reparseLines(caretY-1,caretY);
// step2: insert remaining lines of Value // step2: insert remaining lines of Value
for (int i=1;i<text.length();i++) { for (int i=1;i<text.length();i++) {
bool notInComment = true; bool notInComment = true;
@ -5456,7 +5457,7 @@ int QSynEdit::doInsertTextByNormalMode(const BufferCoord& pos, const QStringList
str = GetLeftSpacing(indentSpaces,true)+trimLeft(str); str = GetLeftSpacing(indentSpaces,true)+trimLeft(str);
} }
properSetLine(caretY - 1, str,false); properSetLine(caretY - 1, str,false);
reparseLines(caretY, caretY+1); reparseLines(caretY-1,caretY);
result++; result++;
} }
bChangeScroll = !mOptions.testFlag(eoScrollPastEol); bChangeScroll = !mOptions.testFlag(eoScrollPastEol);