From 5695a182dcc5c20059ce548645993291b9463b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=BCng?= Date: Tue, 16 Jan 2024 20:07:50 +0100 Subject: [PATCH] don't execute the Goto-Symbol command if there's no symbol to go to --- src/Commands/CmdGotoSymbol.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Commands/CmdGotoSymbol.cpp b/src/Commands/CmdGotoSymbol.cpp index 362382b2..daea34be 100644 --- a/src/Commands/CmdGotoSymbol.cpp +++ b/src/Commands/CmdGotoSymbol.cpp @@ -1,6 +1,6 @@ // This file is part of BowPad. // -// Copyright (C) 2016-2017, 2020-2022 - Stefan Kueng +// Copyright (C) 2016-2017, 2020-2022, 2024 - Stefan Kueng // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -28,9 +28,21 @@ CCmdGotoSymbol::CCmdGotoSymbol(void* obj) bool CCmdGotoSymbol::Execute() { - std::wstring symbolName = CUnicodeUtils::StdGetUnicode(GetSelectedText(SelectionHandling::CurrentWordIfSelectionIsEmpty)); - findReplaceFindFunction(m_pMainWindow, symbolName); - return true; + if (HasActiveDocument()) + { + const auto& doc = GetActiveDocument(); + const auto& funcRegex = CLexStyles::Instance().GetFunctionRegexForLang(doc.GetLanguage()); + if (!funcRegex.empty()) + { + std::wstring symbolName = CUnicodeUtils::StdGetUnicode(GetSelectedText(SelectionHandling::CurrentWordIfSelectionIsEmpty)); + if (!symbolName.empty()) + { + findReplaceFindFunction(m_pMainWindow, symbolName); + return true; + } + } + } + return false; } HRESULT CCmdGotoSymbol::IUICommandHandlerUpdateProperty(REFPROPERTYKEY key, const PROPVARIANT* /*pPropVarCurrentValue*/, PROPVARIANT* pPropVarNewValue)