- fix: "Goto declaration" / "Goto definition" / "Find occurences" not correctly disabled for non-c/c++ files.

This commit is contained in:
Roy Qu 2023-01-07 20:04:51 +08:00
parent 32088a18d0
commit 2ab5efc6fe
4 changed files with 14 additions and 16 deletions

View File

@ -18,6 +18,7 @@ Red Panda C++ Version 2.8
- enhancement: Print syntax colored content.
- enhancement: Correctly handle tab in the exported RTF.
- change: Disable undo limit by default.
- fix: "Goto declaration" / "Goto definition" / "Find occurences" not correctly disabled for non-c/c++ files.
Red Panda C++ Version 2.7

View File

@ -4131,15 +4131,8 @@ void Editor::gotoDeclaration(const QSynedit::BufferCoord &pos)
filename(),
expression,
pos.line);
// QString phrase = getWordAtPosition(this,pos,pBeginPos,pEndPos, WordPurpose::wpInformation);
// if (phrase.isEmpty())
// return;
// PStatement statement = mParser->findStatementOf(
// mFilename,phrase,pos.Line);
if (!statement) {
// pMainWindow->updateStatusbarMessage(tr("Symbol '%1' not found!").arg(phrase));
return;
}
QString filename;
@ -4159,6 +4152,8 @@ void Editor::gotoDeclaration(const QSynedit::BufferCoord &pos)
void Editor::gotoDefinition(const QSynedit::BufferCoord &pos)
{
if (!parser())
return;
QStringList expression = getExpressionAtPosition(pos);
// Find it's definition
@ -4587,7 +4582,7 @@ void Editor::checkSyntaxInBack()
pMainWindow->checkSyntaxInBack(this);
}
const PCppParser &Editor::parser()
const PCppParser &Editor::parser() const
{
return mParser;
}

View File

@ -229,7 +229,7 @@ public:
const QSynedit::BufferCoord& pos);
void resetBookmarks();
const PCppParser &parser();
const PCppParser &parser() const;
void tab() override;
signals:

View File

@ -576,6 +576,10 @@ void MainWindow::updateEditorActions(const Editor *e)
ui->actionGo_to_Line->setEnabled(false);
ui->actionLocate_in_Files_View->setEnabled(false);
ui->actionToggle_Readonly->setEnabled(false);
ui->actionGoto_Declaration->setEnabled(false);
ui->actionGoto_Definition->setEnabled(false);
ui->actionFind_references->setEnabled(false);
} else {
ui->actionAuto_Detect->setEnabled(true);
ui->actionEncode_in_ANSI->setEnabled(true);
@ -632,6 +636,11 @@ void MainWindow::updateEditorActions(const Editor *e)
ui->actionGo_to_Line->setEnabled(true);
ui->actionLocate_in_Files_View->setEnabled(!e->isNew());
ui->actionToggle_Readonly->setEnabled(!e->modified());
//these actions needs parser
ui->actionGoto_Declaration->setEnabled(e->parser()!=nullptr);
ui->actionGoto_Definition->setEnabled(e->parser()!=nullptr);
ui->actionFind_references->setEnabled(e->parser()!=nullptr);
}
updateCompileActions(e);
@ -4785,13 +4794,6 @@ void MainWindow::onEditorContextMenu(const QPoint& pos)
menu.addAction(ui->actionGo_to_Line);
menu.addSeparator();
menu.addAction(ui->actionFile_Properties);
//these actions needs parser
if (editor->parser() && editor->parser()->enabled()) {
ui->actionGoto_Declaration->setEnabled(!editor->parser()->parsing());
ui->actionGoto_Definition->setEnabled(!editor->parser()->parsing());
ui->actionFind_references->setEnabled(!editor->parser()->parsing());
}
} else {
//mouse on gutter