- fix: editors that not in the editing panel should not be syntax checked/ todo parsed/ code analyzed

- fix: editors that not in the editing panel should not trigger breakpoint/bookmark/watch switch
This commit is contained in:
Roy Qu 2022-10-26 22:39:40 +08:00
parent 04e11dbc3b
commit 798607fba0
2 changed files with 35 additions and 25 deletions

View File

@ -35,6 +35,8 @@ Red Panda C++ Version 2.0
- enhancement: auto sort TODO items - enhancement: auto sort TODO items
- fix: Correctly set file's real encoding to ASCII after saving - fix: Correctly set file's real encoding to ASCII after saving
- fix: selection's position not correctly set after input a char / insert string (and causes error under OVERWRITE mode) - fix: selection's position not correctly set after input a char / insert string (and causes error under OVERWRITE mode)
- fix: editors that not in the editing panel should not be syntax checked/ todo parsed/ code analyzed
- fix: editors that not in the editing panel should not trigger breakpoint/bookmark/watch switch
Red Panda C++ Version 1.5 Red Panda C++ Version 1.5

View File

@ -205,7 +205,8 @@ void Editor::loadFile(QString filename) {
} }
//this->setModified(false); //this->setModified(false);
updateCaption(); updateCaption();
pMainWindow->updateForEncodingInfo(this); if (mParentPageControl)
pMainWindow->updateForEncodingInfo(this);
switch(getFileType(mFilename)) { switch(getFileType(mFilename)) {
case FileType::CppSource: case FileType::CppSource:
mUseCppSyntax = true; mUseCppSyntax = true;
@ -235,7 +236,7 @@ void Editor::saveFile(QString filename) {
this->document()->saveToFile(file,encoding, this->document()->saveToFile(file,encoding,
pSettings->editor().defaultEncoding(), pSettings->editor().defaultEncoding(),
mFileEncoding); mFileEncoding);
if (isVisible()) if (isVisible() && mParentPageControl)
pMainWindow->updateForEncodingInfo(this); pMainWindow->updateForEncodingInfo(this);
emit fileSaved(filename, inProject()); emit fileSaved(filename, inProject());
} }
@ -385,8 +386,7 @@ bool Editor::saveAs(const QString &name, bool fromProject){
reparse(false); reparse(false);
if (pSettings->editor().syntaxCheckWhenSave()) checkSyntaxInBack();
pMainWindow->checkSyntaxInBack(this);
reparseTodo(); reparseTodo();
if (!shouldOpenInReadonly()) { if (!shouldOpenInReadonly()) {
@ -400,7 +400,7 @@ bool Editor::saveAs(const QString &name, bool fromProject){
void Editor::activate() void Editor::activate()
{ {
if (mParentPageControl!=nullptr) if (mParentPageControl)
mParentPageControl->setCurrentWidget(this); mParentPageControl->setCurrentWidget(this);
setFocus(); setFocus();
} }
@ -414,7 +414,7 @@ void Editor::setEncodingOption(const QByteArray& encoding) noexcept{
mEncodingOption = encoding; mEncodingOption = encoding;
if (!isNew()) if (!isNew())
loadFile(); loadFile();
else else if (mParentPageControl)
pMainWindow->updateForEncodingInfo(this); pMainWindow->updateForEncodingInfo(this);
if (mProject) { if (mProject) {
PProjectUnit unit = mProject->findUnit(this); PProjectUnit unit = mProject->findUnit(this);
@ -450,7 +450,7 @@ void Editor::setPageControl(QTabWidget *newPageControl)
{ {
if (mParentPageControl==newPageControl) if (mParentPageControl==newPageControl)
return; return;
if (mParentPageControl!=nullptr) { if (mParentPageControl) {
int index = findWidgetInPageControl(mParentPageControl,this); int index = findWidgetInPageControl(mParentPageControl,this);
if (index>=0) if (index>=0)
mParentPageControl->removeTab(index); mParentPageControl->removeTab(index);
@ -1259,9 +1259,11 @@ void Editor::closeEvent(QCloseEvent *)
mCompletionPopup->hide(); mCompletionPopup->hide();
if (pMainWindow->functionTip()) if (pMainWindow->functionTip())
pMainWindow->functionTip()->hide(); pMainWindow->functionTip()->hide();
pMainWindow->updateForEncodingInfo(true); if (mParentPageControl) {
pMainWindow->updateStatusbarForLineCol(true); pMainWindow->updateForEncodingInfo(true);
pMainWindow->updateForStatusbarModeInfo(true); pMainWindow->updateStatusbarForLineCol(true);
pMainWindow->updateForStatusbarModeInfo(true);
}
} }
void Editor::showEvent(QShowEvent */*event*/) void Editor::showEvent(QShowEvent */*event*/)
@ -1280,14 +1282,12 @@ void Editor::showEvent(QShowEvent */*event*/)
&QSynedit::SynEdit::invalidate); &QSynedit::SynEdit::invalidate);
reparse(false); reparse(false);
} }
pMainWindow->debugger()->setIsForProject(inProject()); if (mParentPageControl) {
pMainWindow->bookmarkModel()->setIsForProject(inProject()); pMainWindow->debugger()->setIsForProject(inProject());
pMainWindow->todoModel()->setIsForProject(inProject()); pMainWindow->bookmarkModel()->setIsForProject(inProject());
pMainWindow->todoModel()->setIsForProject(inProject());
}
// if (pSettings->codeCompletion().clearWhenEditorHidden()
// && !inProject()) {
// reparse();
// }
if (!pMainWindow->isClosingAll() if (!pMainWindow->isClosingAll()
&& !pMainWindow->isQuitting()) { && !pMainWindow->isQuitting()) {
if (!inProject() || !pMainWindow->closingProject()) { if (!inProject() || !pMainWindow->closingProject()) {
@ -1295,12 +1295,14 @@ void Editor::showEvent(QShowEvent */*event*/)
reparseTodo(); reparseTodo();
} }
} }
pMainWindow->updateClassBrowserForEditor(this); if (mParentPageControl) {
pMainWindow->updateAppTitle(this); pMainWindow->updateClassBrowserForEditor(this);
pMainWindow->updateEditorActions(this); pMainWindow->updateAppTitle(this);
pMainWindow->updateForEncodingInfo(this); pMainWindow->updateEditorActions(this);
pMainWindow->updateStatusbarForLineCol(this); pMainWindow->updateForEncodingInfo(this);
pMainWindow->updateForStatusbarModeInfo(this); pMainWindow->updateStatusbarForLineCol(this);
pMainWindow->updateForStatusbarModeInfo(this);
}
if (inProject() && !pMainWindow->closingProject()) { if (inProject() && !pMainWindow->closingProject()) {
pMainWindow->setProjectCurrentFile(mFilename); pMainWindow->setProjectCurrentFile(mFilename);
} }
@ -1576,7 +1578,7 @@ void Editor::onStatusChanged(QSynedit::StatusChanges changes)
} }
if (changes.testFlag(QSynedit::scModified)) { if (changes.testFlag(QSynedit::scModified)) {
mCurrentLineModified = true; mCurrentLineModified = true;
if (mParentPageControl!=nullptr) if (mParentPageControl)
mCanAutoSave = true; mCanAutoSave = true;
} }
@ -2696,6 +2698,8 @@ Editor::QuoteStatus Editor::getQuoteStatus()
void Editor::reparse(bool resetParser) void Editor::reparse(bool resetParser)
{ {
if (!mParentPageControl)
return;
if (!pSettings->codeCompletion().enabled()) if (!pSettings->codeCompletion().enabled())
return; return;
if (!highlighter()) if (!highlighter())
@ -2720,6 +2724,8 @@ void Editor::reparse(bool resetParser)
void Editor::reparseTodo() void Editor::reparseTodo()
{ {
if (!mParentPageControl)
return;
if (!highlighter()) if (!highlighter())
return; return;
pMainWindow->todoParser()->parseFile(mFilename, inProject()); pMainWindow->todoParser()->parseFile(mFilename, inProject());
@ -4364,6 +4370,8 @@ void Editor::reformat(bool doReparse)
void Editor::checkSyntaxInBack() void Editor::checkSyntaxInBack()
{ {
if (!mParentPageControl)
return;
if (readOnly()) if (readOnly())
return; return;
if (!highlighter()) if (!highlighter())
@ -4678,7 +4686,7 @@ void Editor::applyColorScheme(const QString& schemeName)
} }
void Editor::updateCaption(const QString& newCaption) { void Editor::updateCaption(const QString& newCaption) {
if (mParentPageControl==nullptr) { if (!mParentPageControl) {
return; return;
} }
int index = mParentPageControl->indexOf(this); int index = mParentPageControl->indexOf(this);