- change: Remove option "clear all symbols when current editor is hidden".

- fix: When opening multiple files, only the active file should be parsed.
This commit is contained in:
Roy Qu 2023-08-11 13:49:09 +08:00
parent 62f7c0a495
commit 739f382f46
9 changed files with 101 additions and 48 deletions

View File

@ -22,6 +22,8 @@ Red Panda C++ Version 2.24
- fix: Wrong code suggestion while inputing numbers in assembly files. - fix: Wrong code suggestion while inputing numbers in assembly files.
- fix: Defines in all files are wrongly cleared when reparsing. - fix: Defines in all files are wrongly cleared when reparsing.
- change: New file created by file template is set as unmodified by default. - change: New file created by file template is set as unmodified by default.
- change: Remove option "clear all symbols when current editor is hidden".
- fix: When opening multiple files, only the active file should be parsed.
Red Panda C++ Version 2.23 Red Panda C++ Version 2.23

View File

@ -217,9 +217,12 @@ Editor::Editor(QWidget *parent, const QString& filename,
this, &Editor::onScrollBarValueChanged); this, &Editor::onScrollBarValueChanged);
mInited=true; mInited=true;
reparse(false); // if (!pMainWindow->openingFiles()
checkSyntaxInBack(); // && !pMainWindow->openingProject()) {
reparseTodo(); // reparse(false);
// checkSyntaxInBack();
// reparseTodo();
// }
} }
Editor::~Editor() { Editor::~Editor() {
@ -1386,7 +1389,8 @@ void Editor::showEvent(QShowEvent */*event*/)
&CppParser::onEndParsing, &CppParser::onEndParsing,
this, this,
&Editor::onEndParsing); &Editor::onEndParsing);
reparse(false); if (!pMainWindow->openingFiles() && !pMainWindow->openingProject())
reparse(false);
} }
if (mParentPageControl) { if (mParentPageControl) {
pMainWindow->debugger()->setIsForProject(inProject()); pMainWindow->debugger()->setIsForProject(inProject());
@ -1395,7 +1399,9 @@ void Editor::showEvent(QShowEvent */*event*/)
} }
if (!pMainWindow->isClosingAll() if (!pMainWindow->isClosingAll()
&& !pMainWindow->isQuitting()) { && !pMainWindow->isQuitting()
&& !pMainWindow->openingFiles()
&& !pMainWindow->openingProject()) {
if (!inProject() || !pMainWindow->closingProject()) { if (!inProject() || !pMainWindow->closingProject()) {
checkSyntaxInBack(); checkSyntaxInBack();
reparseTodo(); reparseTodo();
@ -1418,12 +1424,13 @@ void Editor::showEvent(QShowEvent */*event*/)
void Editor::hideEvent(QHideEvent */*event*/) void Editor::hideEvent(QHideEvent */*event*/)
{ {
if (pSettings->codeCompletion().clearWhenEditorHidden() // if (pSettings->codeCompletion().clearWhenEditorHidden()
&& !inProject() && mParser // && !inProject() && mParser
&& !pMainWindow->isMinimized()) { // && !pMainWindow->isMinimized()) {
//recreate a parser, to totally clean memories the parser uses; // //recreate a parser, to totally clean memories the parser uses;
resetCppParser(mParser); // if (!pMainWindow->openingFiles() && !pMainWindow->openingProject())
} // resetCppParser(mParser);
// }
if (mParser) { if (mParser) {
disconnect(mParser.get(), disconnect(mParser.get(),
&CppParser::onEndParsing, &CppParser::onEndParsing,

View File

@ -117,6 +117,8 @@ MainWindow::MainWindow(QWidget *parent)
mSearchInFilesDialog{nullptr}, mSearchInFilesDialog{nullptr},
mSearchDialog{nullptr}, mSearchDialog{nullptr},
mQuitting{false}, mQuitting{false},
mOpeningFiles{false},
mOpeningProject{false},
mClosingProject{false}, mClosingProject{false},
mCheckSyntaxInBack{false}, mCheckSyntaxInBack{false},
mShouldRemoveAllSettings{false}, mShouldRemoveAllSettings{false},
@ -445,8 +447,8 @@ MainWindow::MainWindow(QWidget *parent)
connect(ui->EditorTabsRight, &EditorsTabWidget::middleButtonClicked, connect(ui->EditorTabsRight, &EditorsTabWidget::middleButtonClicked,
this, &MainWindow::on_EditorTabsRight_tabCloseRequested); this, &MainWindow::on_EditorTabsRight_tabCloseRequested);
//git menu
#ifdef ENABLE_VCS #ifdef ENABLE_VCS
//git menu
connect(ui->menuGit, &QMenu::aboutToShow, connect(ui->menuGit, &QMenu::aboutToShow,
this, &MainWindow::updateVCSActions); this, &MainWindow::updateVCSActions);
#endif #endif
@ -1442,6 +1444,10 @@ void MainWindow::setProjectCurrentFile(const QString &filename)
void MainWindow::openFiles(const QStringList &files) void MainWindow::openFiles(const QStringList &files)
{ {
mOpeningFiles=true;
auto action=finally([this]{
mOpeningFiles=false;
});
mEditorList->beginUpdate(); mEditorList->beginUpdate();
mOpenningFiles = true; mOpenningFiles = true;
auto end = finally([this] { auto end = finally([this] {
@ -1464,8 +1470,12 @@ void MainWindow::openFiles(const QStringList &files)
} }
mEditorList->endUpdate(); mEditorList->endUpdate();
Editor* e=mEditorList->getEditor(); Editor* e=mEditorList->getEditor();
if (e) if (e) {
e->reparse(false);
e->checkSyntaxInBack();
e->reparseTodo();
e->activate(); e->activate();
}
} }
Editor* MainWindow::openFile(QString filename, bool activate, QTabWidget* page) Editor* MainWindow::openFile(QString filename, bool activate, QTabWidget* page)
@ -1523,6 +1533,10 @@ Editor* MainWindow::openFile(QString filename, bool activate, QTabWidget* page)
void MainWindow::openProject(QString filename, bool openFiles) void MainWindow::openProject(QString filename, bool openFiles)
{ {
mOpeningProject=true;
auto action=finally([this]{
mOpeningProject=false;
});
if (!fileExists(filename)) { if (!fileExists(filename)) {
return; return;
} }
@ -3189,6 +3203,10 @@ bool MainWindow::saveLastOpens()
void MainWindow::loadLastOpens() void MainWindow::loadLastOpens()
{ {
mOpeningFiles=true;
auto action=finally([this]{
mOpeningFiles=false;
});
QString filename = includeTrailingPathDelimiter(pSettings->dirs().config()) + DEV_LASTOPENS_FILE; QString filename = includeTrailingPathDelimiter(pSettings->dirs().config()) + DEV_LASTOPENS_FILE;
if (!fileExists(filename)) if (!fileExists(filename))
return; return;
@ -3275,8 +3293,15 @@ void MainWindow::loadLastOpens()
updateEditorActions(); updateEditorActions();
//updateForEncodingInfo(); //updateForEncodingInfo();
} }
if (focusedEditor) if (!focusedEditor) {
focusedEditor = mEditorList->getEditor();
}
if (focusedEditor) {
focusedEditor->reparse(false);
focusedEditor->checkSyntaxInBack();
focusedEditor->reparseTodo();
focusedEditor->activate(); focusedEditor->activate();
}
} }
void MainWindow::updateTools() void MainWindow::updateTools()
@ -7548,7 +7573,8 @@ void MainWindow::reparseNonProjectEditors()
for (int i=0;i<mEditorList->pageCount();i++) { for (int i=0;i<mEditorList->pageCount();i++) {
Editor* e=(*mEditorList)[i]; Editor* e=(*mEditorList)[i];
if (!e->inProject()) { if (!e->inProject()) {
if (!pSettings->codeCompletion().clearWhenEditorHidden() || e->isVisible()) { // if (!pSettings->codeCompletion().clearWhenEditorHidden() || e->isVisible()) {
if (e->isVisible()) {
e->reparse(true); e->reparse(true);
e->checkSyntaxInBack(); e->checkSyntaxInBack();
} }
@ -7959,6 +7985,7 @@ void MainWindow::on_actionRename_Symbol_triggered()
refactor.renameSymbol(editor,oldCaretXY,newWord); refactor.renameSymbol(editor,oldCaretXY,newWord);
editor->reparse(true); editor->reparse(true);
editor->checkSyntaxInBack(); editor->checkSyntaxInBack();
editor->reparseTodo();
} }
@ -10014,3 +10041,13 @@ void MainWindow::on_actionTurtle_Graphics_Manual_triggered()
QDesktopServices::openUrl(QUrl("https://zhuanlan.zhihu.com/p/538666844")); QDesktopServices::openUrl(QUrl("https://zhuanlan.zhihu.com/p/538666844"));
} }
bool MainWindow::openingProject() const
{
return mOpeningProject;
}
bool MainWindow::openingFiles() const
{
return mOpeningFiles;
}

View File

@ -872,6 +872,8 @@ private:
SearchInFileDialog *mSearchInFilesDialog; SearchInFileDialog *mSearchInFilesDialog;
SearchDialog *mSearchDialog; SearchDialog *mSearchDialog;
bool mQuitting; bool mQuitting;
bool mOpeningFiles;
bool mOpeningProject;
bool mClosingProject; bool mClosingProject;
QElapsedTimer mParserTimer; QElapsedTimer mParserTimer;
QFileSystemWatcher mFileSystemWatcher; QFileSystemWatcher mFileSystemWatcher;
@ -1028,6 +1030,8 @@ public:
bool isQuitting() const; bool isQuitting() const;
const std::shared_ptr<VisitHistoryManager> &visitHistoryManager() const; const std::shared_ptr<VisitHistoryManager> &visitHistoryManager() const;
bool closingProject() const; bool closingProject() const;
bool openingFiles() const;
bool openingProject() const;
}; };
extern MainWindow* pMainWindow; extern MainWindow* pMainWindow;

View File

@ -6526,6 +6526,7 @@ void parseFile(PCppParser parser, const QString& fileName, bool inProject, bool
return; return;
if (!parser->enabled()) if (!parser->enabled())
return; return;
// qDebug()<<"parsing "<<fileName;
//delete when finished //delete when finished
CppFileParserThread* thread = new CppFileParserThread(parser,fileName,inProject,onlyIfNotParsed,updateView); CppFileParserThread* thread = new CppFileParserThread(parser,fileName,inProject,onlyIfNotParsed,updateView);
thread->connect(thread, thread->connect(thread,

View File

@ -4166,32 +4166,32 @@ void Settings::CodeCompletion::setShowCodeIns(bool newShowCodeIns)
mShowCodeIns = newShowCodeIns; mShowCodeIns = newShowCodeIns;
} }
bool Settings::CodeCompletion::clearWhenEditorHidden() //bool Settings::CodeCompletion::clearWhenEditorHidden()
{ //{
if (!mShareParser) { // if (!mShareParser) {
#ifdef Q_OS_WIN //#ifdef Q_OS_WIN
MEMORYSTATUSEX statex; // MEMORYSTATUSEX statex;
statex.dwLength = sizeof (statex); // statex.dwLength = sizeof (statex);
GlobalMemoryStatusEx (&statex); // GlobalMemoryStatusEx (&statex);
if (statex.ullAvailPhys < (long long int)2*1024*1024*1024) { // if (statex.ullAvailPhys < (long long int)2*1024*1024*1024) {
return true; // return true;
} // }
#elif defined(Q_OS_LINUX) //#elif defined(Q_OS_LINUX)
struct sysinfo si; // struct sysinfo si;
sysinfo(&si); // sysinfo(&si);
if (si.freeram < (long long int)2*1024*1024*1024) { // if (si.freeram < (long long int)2*1024*1024*1024) {
return true; // return true;
} // }
#endif //#endif
} // }
return mClearWhenEditorHidden; // return mClearWhenEditorHidden;
} //}
void Settings::CodeCompletion::setClearWhenEditorHidden(bool newClearWhenEditorHidden) //void Settings::CodeCompletion::setClearWhenEditorHidden(bool newClearWhenEditorHidden)
{ //{
mClearWhenEditorHidden = newClearWhenEditorHidden; // mClearWhenEditorHidden = newClearWhenEditorHidden;
} //}
int Settings::CodeCompletion::minCharRequired() const int Settings::CodeCompletion::minCharRequired() const
{ {
@ -4357,7 +4357,7 @@ void Settings::CodeCompletion::doSave()
saveValue("ignore_case",mIgnoreCase); saveValue("ignore_case",mIgnoreCase);
saveValue("append_func",mAppendFunc); saveValue("append_func",mAppendFunc);
saveValue("show_code_ins",mShowCodeIns); saveValue("show_code_ins",mShowCodeIns);
saveValue("clear_when_editor_hidden",mClearWhenEditorHidden); //saveValue("clear_when_editor_hidden",mClearWhenEditorHidden);
saveValue("min_char_required",mMinCharRequired); saveValue("min_char_required",mMinCharRequired);
saveValue("hide_symbols_start_with_two_underline", mHideSymbolsStartsWithTwoUnderLine); saveValue("hide_symbols_start_with_two_underline", mHideSymbolsStartsWithTwoUnderLine);
saveValue("hide_symbols_start_with_underline", mHideSymbolsStartsWithUnderLine); saveValue("hide_symbols_start_with_underline", mHideSymbolsStartsWithUnderLine);
@ -4412,7 +4412,7 @@ void Settings::CodeCompletion::doLoad()
// shouldShare = false; // shouldShare = false;
// } // }
//#endif //#endif
mClearWhenEditorHidden = boolValue("clear_when_editor_hidden",doClear); //mClearWhenEditorHidden = boolValue("clear_when_editor_hidden",doClear);
mShareParser = boolValue("share_parser",shouldShare); mShareParser = boolValue("share_parser",shouldShare);
} }

View File

@ -653,8 +653,8 @@ public:
bool showCodeIns() const; bool showCodeIns() const;
void setShowCodeIns(bool newShowCodeIns); void setShowCodeIns(bool newShowCodeIns);
bool clearWhenEditorHidden(); //bool clearWhenEditorHidden();
void setClearWhenEditorHidden(bool newClearWhenEditorHidden); //void setClearWhenEditorHidden(bool newClearWhenEditorHidden);
int minCharRequired() const; int minCharRequired() const;
void setMinCharRequired(int newMinCharRequired); void setMinCharRequired(int newMinCharRequired);
@ -684,7 +684,7 @@ public:
int mMinCharRequired; int mMinCharRequired;
bool mHideSymbolsStartsWithTwoUnderLine; bool mHideSymbolsStartsWithTwoUnderLine;
bool mHideSymbolsStartsWithUnderLine; bool mHideSymbolsStartsWithUnderLine;
bool mClearWhenEditorHidden; //bool mClearWhenEditorHidden;
bool mShareParser; bool mShareParser;
// _Base interface // _Base interface

View File

@ -26,6 +26,7 @@ EditorCodeCompletionWidget::EditorCodeCompletionWidget(const QString& name, cons
ui(new Ui::EditorCodeCompletionWidget) ui(new Ui::EditorCodeCompletionWidget)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->chkClearWhenEditorHidden->setVisible(false);
} }
EditorCodeCompletionWidget::~EditorCodeCompletionWidget() EditorCodeCompletionWidget::~EditorCodeCompletionWidget()
@ -50,7 +51,7 @@ void EditorCodeCompletionWidget::doLoad()
ui->chkIgnoreCases->setChecked(pSettings->codeCompletion().ignoreCase()); ui->chkIgnoreCases->setChecked(pSettings->codeCompletion().ignoreCase());
ui->chkAppendFunc->setChecked(pSettings->codeCompletion().appendFunc()); ui->chkAppendFunc->setChecked(pSettings->codeCompletion().appendFunc());
ui->chkShowCodeIns->setChecked(pSettings->codeCompletion().showCodeIns()); ui->chkShowCodeIns->setChecked(pSettings->codeCompletion().showCodeIns());
ui->chkClearWhenEditorHidden->setChecked(pSettings->codeCompletion().clearWhenEditorHidden()); // ui->chkClearWhenEditorHidden->setChecked(pSettings->codeCompletion().clearWhenEditorHidden());
ui->chkHideSymbolsStartWithTwoUnderline->setChecked(pSettings->codeCompletion().hideSymbolsStartsWithTwoUnderLine()); ui->chkHideSymbolsStartWithTwoUnderline->setChecked(pSettings->codeCompletion().hideSymbolsStartsWithTwoUnderLine());
ui->chkHideSymbolsStartWithUnderline->setChecked(pSettings->codeCompletion().hideSymbolsStartsWithUnderLine()); ui->chkHideSymbolsStartWithUnderline->setChecked(pSettings->codeCompletion().hideSymbolsStartsWithUnderLine());
@ -78,7 +79,7 @@ void EditorCodeCompletionWidget::doSave()
pSettings->codeCompletion().setShowCodeIns(ui->chkShowCodeIns->isChecked()); pSettings->codeCompletion().setShowCodeIns(ui->chkShowCodeIns->isChecked());
pSettings->codeCompletion().setMinCharRequired(ui->spinMinCharRequired->value()); pSettings->codeCompletion().setMinCharRequired(ui->spinMinCharRequired->value());
pSettings->codeCompletion().setClearWhenEditorHidden(ui->chkClearWhenEditorHidden->isChecked()); //pSettings->codeCompletion().setClearWhenEditorHidden(ui->chkClearWhenEditorHidden->isChecked());
pSettings->codeCompletion().setHideSymbolsStartsWithTwoUnderLine(ui->chkHideSymbolsStartWithTwoUnderline->isChecked()); pSettings->codeCompletion().setHideSymbolsStartsWithTwoUnderLine(ui->chkHideSymbolsStartWithTwoUnderline->isChecked());
pSettings->codeCompletion().setHideSymbolsStartsWithUnderLine(ui->chkHideSymbolsStartWithUnderline->isChecked()); pSettings->codeCompletion().setHideSymbolsStartsWithUnderLine(ui->chkHideSymbolsStartWithUnderline->isChecked());

View File

@ -23,6 +23,7 @@ EnvironmentPerformanceWidget::EnvironmentPerformanceWidget(const QString& name,
ui(new Ui::EnvironmentPerformanceWidget) ui(new Ui::EnvironmentPerformanceWidget)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->chkClearWhenEditorHidden->setVisible(false);
} }
EnvironmentPerformanceWidget::~EnvironmentPerformanceWidget() EnvironmentPerformanceWidget::~EnvironmentPerformanceWidget()
@ -32,7 +33,7 @@ EnvironmentPerformanceWidget::~EnvironmentPerformanceWidget()
void EnvironmentPerformanceWidget::doLoad() void EnvironmentPerformanceWidget::doLoad()
{ {
ui->chkClearWhenEditorHidden->setChecked(pSettings->codeCompletion().clearWhenEditorHidden()); // ui->chkClearWhenEditorHidden->setChecked(pSettings->codeCompletion().clearWhenEditorHidden());
//#ifdef Q_OS_WIN //#ifdef Q_OS_WIN
// MEMORYSTATUSEX statex; // MEMORYSTATUSEX statex;
@ -58,7 +59,7 @@ void EnvironmentPerformanceWidget::doLoad()
void EnvironmentPerformanceWidget::doSave() void EnvironmentPerformanceWidget::doSave()
{ {
pSettings->codeCompletion().setClearWhenEditorHidden(ui->chkClearWhenEditorHidden->isChecked()); //pSettings->codeCompletion().setClearWhenEditorHidden(ui->chkClearWhenEditorHidden->isChecked());
pSettings->codeCompletion().setShareParser(ui->chkEditorsShareParser->isChecked()); pSettings->codeCompletion().setShareParser(ui->chkEditorsShareParser->isChecked());
pSettings->codeCompletion().save(); pSettings->codeCompletion().save();