debugger: Show run to cursor in editor's context menu (#35745)

This also fixed a bug where evaluate selected text was an available
option when the selected debug session was terminated.


Release Notes:

- debugger: add Run to Cursor back to Editor's context menu

Co-authored-by: Remco Smits <djsmits12@gmail.com>
This commit is contained in:
Anthony Eid 2025-08-06 15:45:22 -04:00 committed by GitHub
parent f9038f6189
commit 010441e23b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 91 additions and 49 deletions

View file

@ -1,8 +1,8 @@
use crate::{
Copy, CopyAndTrim, CopyPermalinkToLine, Cut, DisplayPoint, DisplaySnapshot, Editor,
EvaluateSelectedText, FindAllReferences, GoToDeclaration, GoToDefinition, GoToImplementation,
GoToTypeDefinition, Paste, Rename, RevealInFileManager, SelectMode, SelectionEffects,
SelectionExt, ToDisplayPoint, ToggleCodeActions,
GoToTypeDefinition, Paste, Rename, RevealInFileManager, RunToCursor, SelectMode,
SelectionEffects, SelectionExt, ToDisplayPoint, ToggleCodeActions,
actions::{Format, FormatSelections},
selections_collection::SelectionsCollection,
};
@ -200,15 +200,21 @@ pub fn deploy_context_menu(
});
let evaluate_selection = window.is_action_available(&EvaluateSelectedText, cx);
let run_to_cursor = window.is_action_available(&RunToCursor, cx);
ui::ContextMenu::build(window, cx, |menu, _window, _cx| {
let builder = menu
.on_blur_subscription(Subscription::new(|| {}))
.when(evaluate_selection && has_selections, |builder| {
builder
.action("Evaluate Selection", Box::new(EvaluateSelectedText))
.separator()
.when(run_to_cursor, |builder| {
builder.action("Run to Cursor", Box::new(RunToCursor))
})
.when(evaluate_selection && has_selections, |builder| {
builder.action("Evaluate Selection", Box::new(EvaluateSelectedText))
})
.when(
run_to_cursor || (evaluate_selection && has_selections),
|builder| builder.separator(),
)
.action("Go to Definition", Box::new(GoToDefinition))
.action("Go to Declaration", Box::new(GoToDeclaration))
.action("Go to Type Definition", Box::new(GoToTypeDefinition))