fix: folding range calculation error when open file
This commit is contained in:
parent
5d3a933932
commit
aac17beb85
|
@ -1606,10 +1606,10 @@ int QSynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent
|
||||||
if (mSyntaxer->language() != ProgrammingLanguage::CPP)
|
if (mSyntaxer->language() != ProgrammingLanguage::CPP)
|
||||||
return indentSpaces;
|
return indentSpaces;
|
||||||
SyntaxState rangePreceeding = mDocument->getSyntaxState(startLine-1);
|
SyntaxState rangePreceeding = mDocument->getSyntaxState(startLine-1);
|
||||||
mSyntaxer->setState(rangePreceeding);
|
|
||||||
if (addIndent) {
|
if (addIndent) {
|
||||||
// QString trimmedS = s.trimmed();
|
// QString trimmedS = s.trimmed();
|
||||||
QString trimmedLineText = lineText.trimmed();
|
QString trimmedLineText = lineText.trimmed();
|
||||||
|
mSyntaxer->setState(rangePreceeding);
|
||||||
mSyntaxer->setLine(trimmedLineText,line-1);
|
mSyntaxer->setLine(trimmedLineText,line-1);
|
||||||
int statePrePre;
|
int statePrePre;
|
||||||
if (startLine>1) {
|
if (startLine>1) {
|
||||||
|
@ -3336,7 +3336,7 @@ int QSynEdit::scanFrom(int Index, int canStopIndex)
|
||||||
mSyntaxer->nextToEol();
|
mSyntaxer->nextToEol();
|
||||||
iRange = mSyntaxer->getState();
|
iRange = mSyntaxer->getState();
|
||||||
if (Result > canStopIndex){
|
if (Result > canStopIndex){
|
||||||
if (mDocument->getSyntaxState(Result).state == iRange.state
|
if (mDocument->getSyntaxState(Result) == iRange
|
||||||
&& mDocument->getSyntaxState(Result).blockLevel == iRange.blockLevel
|
&& mDocument->getSyntaxState(Result).blockLevel == iRange.blockLevel
|
||||||
&& mDocument->getSyntaxState(Result).blockStarted == iRange.blockStarted
|
&& mDocument->getSyntaxState(Result).blockStarted == iRange.blockStarted
|
||||||
&& mDocument->getSyntaxState(Result).blockEnded == iRange.blockEnded
|
&& mDocument->getSyntaxState(Result).blockEnded == iRange.blockEnded
|
||||||
|
|
|
@ -1571,6 +1571,11 @@ void CppSyntaxer::setLine(const QString &newLine, int lineNumber)
|
||||||
mLineSize = mLine.size();
|
mLineSize = mLine.size();
|
||||||
mLineNumber = lineNumber;
|
mLineNumber = lineNumber;
|
||||||
mRun = 0;
|
mRun = 0;
|
||||||
|
mRange.blockStarted = 0;
|
||||||
|
mRange.blockEnded = 0;
|
||||||
|
mRange.blockEndedLastLine = 0;
|
||||||
|
mRange.lastUnindent=IndentInfo{IndentType::None,0};
|
||||||
|
mRange.hasTrailingSpaces = false;
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1383,6 +1383,11 @@ void GLSLSyntaxer::setLine(const QString &newLine, int lineNumber)
|
||||||
mLine = mLineString.data();
|
mLine = mLineString.data();
|
||||||
mLineNumber = lineNumber;
|
mLineNumber = lineNumber;
|
||||||
mRun = 0;
|
mRun = 0;
|
||||||
|
mRange.blockStarted = 0;
|
||||||
|
mRange.blockEnded = 0;
|
||||||
|
mRange.blockEndedLastLine = 0;
|
||||||
|
mRange.lastUnindent=IndentInfo{IndentType::None,0};
|
||||||
|
mRange.hasTrailingSpaces = false;
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue