From bbe79297efb77304253fe2b6073fb64484eec964 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 5 Mar 2024 15:29:25 +0800 Subject: [PATCH] fix: Deadlock while openning files that contains '\t' fix: Optimize file openning --- RedPandaIDE/editor.cpp | 17 +++++++++-------- libs/qsynedit/qsynedit/qsynedit.cpp | 2 +- libs/qsynedit/qsynedit/syntaxer/syntaxer.cpp | 2 +- libs/qsynedit/qsynedit/syntaxer/textfile.cpp | 4 ++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index e0cfd9b6..656f5f66 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -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) diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index a3011d3f..bb721a39 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -6522,7 +6522,7 @@ void QSynEdit::setGutterWidth(int Value) Value = std::max(Value, 0); if (mGutterWidth != Value) { mGutterWidth = Value; - onSizeOrFontChanged(false); + // onSizeOrFontChanged(false); invalidate(); } } diff --git a/libs/qsynedit/qsynedit/syntaxer/syntaxer.cpp b/libs/qsynedit/qsynedit/syntaxer/syntaxer.cpp index 727f761d..cb516e2a 100644 --- a/libs/qsynedit/qsynedit/syntaxer/syntaxer.cpp +++ b/libs/qsynedit/qsynedit/syntaxer/syntaxer.cpp @@ -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) diff --git a/libs/qsynedit/qsynedit/syntaxer/textfile.cpp b/libs/qsynedit/qsynedit/syntaxer/textfile.cpp index 20edb5e3..c082feba 100644 --- a/libs/qsynedit/qsynedit/syntaxer/textfile.cpp +++ b/libs/qsynedit/qsynedit/syntaxer/textfile.cpp @@ -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();