- enhancement: Parser not correctly released if save a c file to non-c file.

This commit is contained in:
Roy Qu 2023-02-16 18:36:15 +08:00
parent da3bcf1c6a
commit 885470782c
2 changed files with 26 additions and 24 deletions

View File

@ -28,6 +28,7 @@ Red Panda C++ Version 2.12
- fix: Wrong selection position after delete in column mode.
- enhancement: Syntax highlight and basic code completion for lua.
- enhancement: Basic code completion for xmake.lua.
- enhancement: Parser not correctly released if save a c file to non-c file.
Red Panda C++ Version 2.11

View File

@ -473,14 +473,15 @@ bool Editor::saveAs(const QString &name, bool fromProject){
}
applyColorScheme(pSettings->editor().colorScheme());
if (!inProject())
if (!inProject()) {
initParser();
reparse(false);
reparseTodo();
}
if (pSettings->editor().syntaxCheckWhenSave())
checkSyntaxInBack();
if (!inProject())
reparseTodo();
if (!shouldOpenInReadonly()) {
setReadOnly(false);
@ -2801,15 +2802,11 @@ bool Editor::handleCodeCompletion(QChar key)
void Editor::initParser()
{
if (pSettings->codeCompletion().shareParser()) {
if (pSettings->codeCompletion().enabled()
&& (syntaxer() && syntaxer()->language() == QSynedit::ProgrammingLanguage::CPP)
) {
&& (isCFile(mFilename) || isHFile(mFilename))) {
if (pSettings->codeCompletion().shareParser()) {
mParser = sharedParser(mUseCppSyntax?ParserLanguage::CPlusPlus:ParserLanguage::C);
}
return;
}
} else {
mParser = std::make_shared<CppParser>();
if (mUseCppSyntax) {
mParser->setLanguage(ParserLanguage::CPlusPlus);
@ -2825,6 +2822,10 @@ void Editor::initParser()
pSettings->codeCompletion().enabled() &&
(syntaxer() && syntaxer()->language() == QSynedit::ProgrammingLanguage::CPP));
}
} else {
mParser = nullptr;
}
}
Editor::QuoteStatus Editor::getQuoteStatus()
{
@ -3263,9 +3264,9 @@ void Editor::showCompletion(const QString& preWord,bool autoComplete, CodeComple
mCompletionPopup->setRecordUsage(pSettings->codeCompletion().recordUsage());
mCompletionPopup->setSortByScope(pSettings->codeCompletion().sortByScope());
mCompletionPopup->setShowKeywords(pSettings->codeCompletion().showKeywords());
if (type!=CodeCompletionType::Normal)
if (type!=CodeCompletionType::Normal) {
mCompletionPopup->setShowCodeSnippets(false);
else {
} else {
mCompletionPopup->setShowCodeSnippets(pSettings->codeCompletion().showCodeIns());
if (pSettings->codeCompletion().showCodeIns()) {
mCompletionPopup->setCodeSnippets(pMainWindow->codeSnippetManager()->snippets());