fix: Deadlock while openning files that contains '\t'

fix: Optimize file openning
This commit is contained in:
Roy Qu 2024-03-05 15:29:25 +08:00
parent 52dc8cf286
commit bbe79297ef
4 changed files with 13 additions and 12 deletions

View File

@ -94,6 +94,15 @@ Editor::Editor(QWidget *parent, const QString& filename,
}
QFileInfo fileInfo(mFilename);
QSynedit::PSyntaxer syntaxer;
syntaxer = syntaxerManager.getSyntaxer(mFilename);
if (syntaxer) {
setSyntaxer(syntaxer);
setFormatter(syntaxerManager.getFormatter(syntaxer->language()));
setUseCodeFolding(true);
} else {
setUseCodeFolding(false);
}
if (mProject && mEncodingOption==ENCODING_PROJECT) {
mEncodingOption=mProject->options().encoding;
}
@ -107,15 +116,7 @@ Editor::Editor(QWidget *parent, const QString& filename,
e.reason());
}
}
syntaxer = syntaxerManager.getSyntaxer(mFilename);
resolveAutoDetectEncodingOption();
if (syntaxer) {
setSyntaxer(syntaxer);
setFormatter(syntaxerManager.getFormatter(syntaxer->language()));
setUseCodeFolding(true);
} else {
setUseCodeFolding(false);
}
if (mProject) {
if (syntaxer && syntaxer->language() == QSynedit::ProgrammingLanguage::CPP)

View File

@ -6522,7 +6522,7 @@ void QSynEdit::setGutterWidth(int Value)
Value = std::max(Value, 0);
if (mGutterWidth != Value) {
mGutterWidth = Value;
onSizeOrFontChanged(false);
// onSizeOrFontChanged(false);
invalidate();
}
}

View File

@ -114,7 +114,7 @@ bool Syntaxer::supportBraceLevel()
bool Syntaxer::isSpaceChar(const QChar &ch)
{
return ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n';
return ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n' || ch.isSpace();
}
bool Syntaxer::isWordBreakChar(const QChar &ch)

View File

@ -29,7 +29,7 @@ TextSyntaxer::TextSyntaxer()
void TextSyntaxer::procSpace()
{
mTokenID = TokenId::Space;
while (mLine[mRun]!=0 && mLine[mRun].isSpace())
while (mLine[mRun]!=0 && isSpaceChar(mLine[mRun]))
mRun++;
if (mRun>=mStringLen)
mHasTrailingSpaces = true;
@ -100,7 +100,7 @@ void TextSyntaxer::next()
mTokenPos = mRun;
if (mLine[mRun].unicode()==0) {
procNull();
} else if (isSpaceChar(mLine[mRun].unicode())) {
} else if (isSpaceChar(mLine[mRun])) {
procSpace();
} else {
procText();