Skip to content

Commit 7f838df

Browse files
authored
When "evaluate in debug console" is run without a selection, send the full line (microsoft#163904)
Fix microsoft#153721
1 parent 5170238 commit 7f838df

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/vs/workbench/contrib/debug/browser/debug.contribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ registerDebugCommandPaletteItem(FOCUS_REPL_ID, { value: nls.localize({ comment:
122122
registerDebugCommandPaletteItem(JUMP_TO_CURSOR_ID, { value: nls.localize('jumpToCursor', "Jump to Cursor"), original: 'Jump to Cursor' }, CONTEXT_JUMP_TO_CURSOR_SUPPORTED);
123123
registerDebugCommandPaletteItem(JUMP_TO_CURSOR_ID, { value: nls.localize('SetNextStatement', "Set Next Statement"), original: 'Set Next Statement' }, CONTEXT_JUMP_TO_CURSOR_SUPPORTED);
124124
registerDebugCommandPaletteItem(RunToCursorAction.ID, { value: RunToCursorAction.LABEL, original: 'Run to Cursor' }, ContextKeyExpr.and(CONTEXT_IN_DEBUG_MODE, CONTEXT_DEBUG_STATE.isEqualTo('stopped')));
125-
registerDebugCommandPaletteItem(SelectionToReplAction.ID, { value: SelectionToReplAction.LABEL, original: 'Evaluate in Debug Console' }, ContextKeyExpr.and(EditorContextKeys.hasNonEmptySelection, CONTEXT_IN_DEBUG_MODE));
125+
registerDebugCommandPaletteItem(SelectionToReplAction.ID, { value: SelectionToReplAction.LABEL, original: 'Evaluate in Debug Console' }, CONTEXT_IN_DEBUG_MODE);
126126
registerDebugCommandPaletteItem(SelectionToWatchExpressionsAction.ID, { value: SelectionToWatchExpressionsAction.LABEL, original: 'Add to Watch' }, ContextKeyExpr.and(EditorContextKeys.hasNonEmptySelection, CONTEXT_IN_DEBUG_MODE));
127127
registerDebugCommandPaletteItem(TOGGLE_INLINE_BREAKPOINT_ID, { value: nls.localize('inlineBreakpoint', "Inline Breakpoint"), original: 'Inline Breakpoint' });
128128
registerDebugCommandPaletteItem(DEBUG_START_COMMAND_ID, DEBUG_START_LABEL, ContextKeyExpr.and(CONTEXT_DEBUGGERS_AVAILABLE, CONTEXT_DEBUG_STATE.notEqualsTo(getStateLabel(State.Initializing))));

src/vs/workbench/contrib/debug/browser/debugEditorActions.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export class SelectionToReplAction extends EditorAction {
245245
id: SelectionToReplAction.ID,
246246
label: SelectionToReplAction.LABEL,
247247
alias: 'Debug: Evaluate in Console',
248-
precondition: ContextKeyExpr.and(EditorContextKeys.hasNonEmptySelection, CONTEXT_IN_DEBUG_MODE, EditorContextKeys.editorTextFocus),
248+
precondition: ContextKeyExpr.and(CONTEXT_IN_DEBUG_MODE, EditorContextKeys.editorTextFocus),
249249
contextMenuOpts: {
250250
group: 'debug',
251251
order: 0
@@ -262,7 +262,14 @@ export class SelectionToReplAction extends EditorAction {
262262
return;
263263
}
264264

265-
const text = editor.getModel().getValueInRange(editor.getSelection());
265+
const selection = editor.getSelection();
266+
let text: string;
267+
if (selection.isEmpty()) {
268+
text = editor.getModel().getLineContent(selection.selectionStartLineNumber).trim();
269+
} else {
270+
text = editor.getModel().getValueInRange(selection);
271+
}
272+
266273
await session.addReplExpression(viewModel.focusedStackFrame!, text);
267274
await viewsService.openView(REPL_VIEW_ID, false);
268275
}

0 commit comments

Comments
 (0)