- enhancement: Parser not correctly released if save a c file to non-c file.
This commit is contained in:
parent
da3bcf1c6a
commit
885470782c
1
NEWS.md
1
NEWS.md
|
@ -28,6 +28,7 @@ Red Panda C++ Version 2.12
|
||||||
- fix: Wrong selection position after delete in column mode.
|
- fix: Wrong selection position after delete in column mode.
|
||||||
- enhancement: Syntax highlight and basic code completion for lua.
|
- enhancement: Syntax highlight and basic code completion for lua.
|
||||||
- enhancement: Basic code completion for xmake.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
|
Red Panda C++ Version 2.11
|
||||||
|
|
||||||
|
|
|
@ -473,14 +473,15 @@ bool Editor::saveAs(const QString &name, bool fromProject){
|
||||||
}
|
}
|
||||||
applyColorScheme(pSettings->editor().colorScheme());
|
applyColorScheme(pSettings->editor().colorScheme());
|
||||||
|
|
||||||
if (!inProject())
|
if (!inProject()) {
|
||||||
|
initParser();
|
||||||
reparse(false);
|
reparse(false);
|
||||||
|
reparseTodo();
|
||||||
|
}
|
||||||
|
|
||||||
if (pSettings->editor().syntaxCheckWhenSave())
|
if (pSettings->editor().syntaxCheckWhenSave())
|
||||||
checkSyntaxInBack();
|
checkSyntaxInBack();
|
||||||
|
|
||||||
if (!inProject())
|
|
||||||
reparseTodo();
|
|
||||||
|
|
||||||
if (!shouldOpenInReadonly()) {
|
if (!shouldOpenInReadonly()) {
|
||||||
setReadOnly(false);
|
setReadOnly(false);
|
||||||
|
@ -2801,29 +2802,29 @@ bool Editor::handleCodeCompletion(QChar key)
|
||||||
|
|
||||||
void Editor::initParser()
|
void Editor::initParser()
|
||||||
{
|
{
|
||||||
if (pSettings->codeCompletion().shareParser()) {
|
if (pSettings->codeCompletion().enabled()
|
||||||
if (pSettings->codeCompletion().enabled()
|
&& (isCFile(mFilename) || isHFile(mFilename))) {
|
||||||
&& (syntaxer() && syntaxer()->language() == QSynedit::ProgrammingLanguage::CPP)
|
if (pSettings->codeCompletion().shareParser()) {
|
||||||
) {
|
|
||||||
mParser = sharedParser(mUseCppSyntax?ParserLanguage::CPlusPlus:ParserLanguage::C);
|
mParser = sharedParser(mUseCppSyntax?ParserLanguage::CPlusPlus:ParserLanguage::C);
|
||||||
|
} else {
|
||||||
|
mParser = std::make_shared<CppParser>();
|
||||||
|
if (mUseCppSyntax) {
|
||||||
|
mParser->setLanguage(ParserLanguage::CPlusPlus);
|
||||||
|
} else {
|
||||||
|
mParser->setLanguage(ParserLanguage::C);
|
||||||
|
}
|
||||||
|
mParser->setOnGetFileStream(
|
||||||
|
std::bind(
|
||||||
|
&EditorList::getContentFromOpenedEditor,pMainWindow->editorList(),
|
||||||
|
std::placeholders::_1, std::placeholders::_2));
|
||||||
|
resetCppParser(mParser);
|
||||||
|
mParser->setEnabled(
|
||||||
|
pSettings->codeCompletion().enabled() &&
|
||||||
|
(syntaxer() && syntaxer()->language() == QSynedit::ProgrammingLanguage::CPP));
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mParser = std::make_shared<CppParser>();
|
|
||||||
if (mUseCppSyntax) {
|
|
||||||
mParser->setLanguage(ParserLanguage::CPlusPlus);
|
|
||||||
} else {
|
} else {
|
||||||
mParser->setLanguage(ParserLanguage::C);
|
mParser = nullptr;
|
||||||
}
|
}
|
||||||
mParser->setOnGetFileStream(
|
|
||||||
std::bind(
|
|
||||||
&EditorList::getContentFromOpenedEditor,pMainWindow->editorList(),
|
|
||||||
std::placeholders::_1, std::placeholders::_2));
|
|
||||||
resetCppParser(mParser);
|
|
||||||
mParser->setEnabled(
|
|
||||||
pSettings->codeCompletion().enabled() &&
|
|
||||||
(syntaxer() && syntaxer()->language() == QSynedit::ProgrammingLanguage::CPP));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Editor::QuoteStatus Editor::getQuoteStatus()
|
Editor::QuoteStatus Editor::getQuoteStatus()
|
||||||
|
@ -3263,9 +3264,9 @@ void Editor::showCompletion(const QString& preWord,bool autoComplete, CodeComple
|
||||||
mCompletionPopup->setRecordUsage(pSettings->codeCompletion().recordUsage());
|
mCompletionPopup->setRecordUsage(pSettings->codeCompletion().recordUsage());
|
||||||
mCompletionPopup->setSortByScope(pSettings->codeCompletion().sortByScope());
|
mCompletionPopup->setSortByScope(pSettings->codeCompletion().sortByScope());
|
||||||
mCompletionPopup->setShowKeywords(pSettings->codeCompletion().showKeywords());
|
mCompletionPopup->setShowKeywords(pSettings->codeCompletion().showKeywords());
|
||||||
if (type!=CodeCompletionType::Normal)
|
if (type!=CodeCompletionType::Normal) {
|
||||||
mCompletionPopup->setShowCodeSnippets(false);
|
mCompletionPopup->setShowCodeSnippets(false);
|
||||||
else {
|
} else {
|
||||||
mCompletionPopup->setShowCodeSnippets(pSettings->codeCompletion().showCodeIns());
|
mCompletionPopup->setShowCodeSnippets(pSettings->codeCompletion().showCodeIns());
|
||||||
if (pSettings->codeCompletion().showCodeIns()) {
|
if (pSettings->codeCompletion().showCodeIns()) {
|
||||||
mCompletionPopup->setCodeSnippets(pMainWindow->codeSnippetManager()->snippets());
|
mCompletionPopup->setCodeSnippets(pMainWindow->codeSnippetManager()->snippets());
|
||||||
|
|
Loading…
Reference in New Issue