Skip to content

Commit

Permalink
don't execute the Goto-Symbol command if there's no symbol to go to
Browse files Browse the repository at this point in the history
  • Loading branch information
stefankueng committed Jan 16, 2024
1 parent 1134801 commit 5695a18
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/Commands/CmdGotoSymbol.cpp
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5695a18

Please sign in to comment.