diff --git a/IDE/src/Commands.bf b/IDE/src/Commands.bf index 433d3e82..d3d531cd 100644 --- a/IDE/src/Commands.bf +++ b/IDE/src/Commands.bf @@ -200,7 +200,7 @@ namespace IDE Add("Find in Files", new => gApp.Cmd_Find); Add("Find Next", new => gApp.Cmd_FindNext); Add("Find Prev", new => gApp.Cmd_FindPrev); - Add("Goto Definition", new => gApp.GoToDefinition); + Add("Goto Definition", new () => gApp.GoToDefinition(true)); Add("Goto Line", new => gApp.Cmd_GotoLine); Add("Goto Method", new => gApp.Cmd_GotoMethod); Add("Goto Next Item", new => gApp.Cmd_GotoNextItem); diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index 4c0c6800..bdc82e4d 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -3735,15 +3735,20 @@ namespace IDE mInDisassemblyView = true; } - public void GoToDefinition() + public void GoToDefinition(bool force) { var sourceViewPanel = GetActiveSourceViewPanel(); if (sourceViewPanel != null) { - int line; - int lineChar; - sourceViewPanel.mEditWidget.Content.GetCursorLineChar(out line, out lineChar); + if (!force) + { + if ((!sourceViewPanel.mIsBeefSource) || (sourceViewPanel.mProjectSource == null)) + return; + } + if ((!sourceViewPanel.mEditWidget.Content.GetCursorLineChar(var line, var lineChar)) && (!force)) + return; + if (!sourceViewPanel.HasTextAtCursor()) return; diff --git a/IDE/src/ui/RenameSymbolDialog.bf b/IDE/src/ui/RenameSymbolDialog.bf index ba6cb9b7..1f628ca3 100644 --- a/IDE/src/ui/RenameSymbolDialog.bf +++ b/IDE/src/ui/RenameSymbolDialog.bf @@ -801,7 +801,7 @@ namespace IDE.ui if (gApp.mBfResolveCompiler.HasResolvedAll()) { Close(); - gApp.GoToDefinition(); + gApp.GoToDefinition(true); } if (mSourceViewPanel.EditWidget.Content.CursorTextPos != mCursorPos) diff --git a/IDE/src/ui/SourceEditWidgetContent.bf b/IDE/src/ui/SourceEditWidgetContent.bf index d5e53dcc..635afa6f 100644 --- a/IDE/src/ui/SourceEditWidgetContent.bf +++ b/IDE/src/ui/SourceEditWidgetContent.bf @@ -2967,7 +2967,7 @@ namespace IDE.ui if ((btn == 0) && (mWidgetWindow.IsKeyDown(.Control)) && (x == origX) && (y == origY)) { - gApp.GoToDefinition(); + gApp.GoToDefinition(false); return; } @@ -3003,7 +3003,7 @@ namespace IDE.ui menuItem = menu.AddItem("Go to Definition"); menuItem.SetDisabled(!hasText); - menuItem.mOnMenuItemSelected.Add(new (evt) => gApp.GoToDefinition()); + menuItem.mOnMenuItemSelected.Add(new (evt) => gApp.GoToDefinition(true)); menuItem = menu.AddItem("Rename Symbol"); menuItem.SetDisabled(!hasText);