From f0c01e03aafa49d940fc4a85db0a971d193982d6 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 20 Feb 2024 10:31:12 +0800 Subject: [PATCH] - Fix: Can't goto definition/declaration into files that not saved. --- NEWS.md | 1 + RedPandaIDE/editor.cpp | 5 +++-- libs/qsynedit/qsynedit/syntaxer/cpp.h | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9df7e5e2..907a508d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -42,6 +42,7 @@ Red Panda C++ Version 2.26 - Enhancement: add qmake variable to control preference of UTF-8 compatible OpenConsole.exe on Windows. - Enhancement: add Windows arm64 package. - Fix: Force to use debug server when debugging with lldb-mi to fix input/output on Windows. + - Fix: Can't goto definition/declaration into files that not saved. Red Panda C++ Version 2.25 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index c35bb347..683878c2 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -1373,7 +1373,6 @@ void Editor::mouseReleaseEvent(QMouseEvent *event) QString filename = mParser->getHeaderFileName(mFilename,s); pMainWindow->openFile(filename); return; - } else if (mParser->enabled()) { gotoDefinition(p); return; @@ -4674,7 +4673,9 @@ void Editor::gotoDefinition(const QSynedit::BufferCoord &pos) filename = statement->definitionFileName; line = statement->definitionLine; } - Editor *e = pMainWindow->openFile(filename); + Editor *e = pMainWindow->editorList()->getOpenedEditorByFilename(filename); + if (!e) + e = pMainWindow->openFile(filename); if (e) { e->setCaretPositionAndActivate(line,1); } diff --git a/libs/qsynedit/qsynedit/syntaxer/cpp.h b/libs/qsynedit/qsynedit/syntaxer/cpp.h index 1dba1fb7..48430541 100644 --- a/libs/qsynedit/qsynedit/syntaxer/cpp.h +++ b/libs/qsynedit/qsynedit/syntaxer/cpp.h @@ -50,7 +50,7 @@ class CppSyntaxer: public Syntaxer rsDocstring, rsStringEscapeSeq, rsRawString, rsSpace,rsRawStringNotEscaping,rsRawStringEnd,rsChar, - rsDefineIdentifier, rsDefineRemaining + rsDefineIdentifier, rsDefineRemaining, }; public: