mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Show "Evaluate in debug console" expressions in debug console's input history (#215490)
Fix #214820
This commit is contained in:
parent
1474750c61
commit
d9d04e97b7
|
@ -14,6 +14,7 @@ import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
|||
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures';
|
||||
import { MessageController } from 'vs/editor/contrib/message/browser/messageController';
|
||||
import * as nls from 'vs/nls';
|
||||
import { ILocalizedString } from 'vs/platform/action/common/action';
|
||||
import { Action2, MenuId, registerAction2 } from 'vs/platform/actions/common/actions';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
@ -22,14 +23,14 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
|
|||
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
|
||||
import { PanelFocusContext } from 'vs/workbench/common/contextkeys';
|
||||
import { IViewsService } from 'vs/workbench/services/views/common/viewsService';
|
||||
import { openBreakpointSource } from 'vs/workbench/contrib/debug/browser/breakpointsView';
|
||||
import { DisassemblyView } from 'vs/workbench/contrib/debug/browser/disassemblyView';
|
||||
import { BREAKPOINT_EDITOR_CONTRIBUTION_ID, BreakpointWidgetContext, CONTEXT_CALLSTACK_ITEM_TYPE, CONTEXT_DEBUGGERS_AVAILABLE, CONTEXT_DEBUG_STATE, CONTEXT_DISASSEMBLE_REQUEST_SUPPORTED, CONTEXT_DISASSEMBLY_VIEW_FOCUS, CONTEXT_EXCEPTION_WIDGET_VISIBLE, CONTEXT_FOCUSED_STACK_FRAME_HAS_INSTRUCTION_POINTER_REFERENCE, CONTEXT_IN_DEBUG_MODE, CONTEXT_LANGUAGE_SUPPORTS_DISASSEMBLE_REQUEST, CONTEXT_STEP_INTO_TARGETS_SUPPORTED, EDITOR_CONTRIBUTION_ID, IBreakpointEditorContribution, IDebugConfiguration, IDebugEditorContribution, IDebugService, REPL_VIEW_ID, WATCH_VIEW_ID } from 'vs/workbench/contrib/debug/common/debug';
|
||||
import { Repl } from 'vs/workbench/contrib/debug/browser/repl';
|
||||
import { BREAKPOINT_EDITOR_CONTRIBUTION_ID, BreakpointWidgetContext, CONTEXT_CALLSTACK_ITEM_TYPE, CONTEXT_DEBUG_STATE, CONTEXT_DEBUGGERS_AVAILABLE, CONTEXT_DISASSEMBLE_REQUEST_SUPPORTED, CONTEXT_DISASSEMBLY_VIEW_FOCUS, CONTEXT_EXCEPTION_WIDGET_VISIBLE, CONTEXT_FOCUSED_STACK_FRAME_HAS_INSTRUCTION_POINTER_REFERENCE, CONTEXT_IN_DEBUG_MODE, CONTEXT_LANGUAGE_SUPPORTS_DISASSEMBLE_REQUEST, CONTEXT_STEP_INTO_TARGETS_SUPPORTED, EDITOR_CONTRIBUTION_ID, IBreakpointEditorContribution, IDebugConfiguration, IDebugEditorContribution, IDebugService, REPL_VIEW_ID, WATCH_VIEW_ID } from 'vs/workbench/contrib/debug/common/debug';
|
||||
import { getEvaluatableExpressionAtPosition } from 'vs/workbench/contrib/debug/common/debugUtils';
|
||||
import { DisassemblyViewInput } from 'vs/workbench/contrib/debug/common/disassemblyViewInput';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ILocalizedString } from 'vs/platform/action/common/action';
|
||||
import { IViewsService } from 'vs/workbench/services/views/common/viewsService';
|
||||
|
||||
class ToggleBreakpointAction extends Action2 {
|
||||
constructor() {
|
||||
|
@ -368,8 +369,8 @@ export class SelectionToReplAction extends EditorAction {
|
|||
text = editor.getModel().getValueInRange(selection);
|
||||
}
|
||||
|
||||
await session.addReplExpression(viewModel.focusedStackFrame, text);
|
||||
await viewsService.openView(REPL_VIEW_ID, false);
|
||||
const replView = await viewsService.openView(REPL_VIEW_ID, false) as Repl | undefined;
|
||||
replView?.sendReplInput(text);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1521,8 +1521,8 @@ export class DebugSession implements IDebugSession, IDisposable {
|
|||
this.repl.removeReplExpressions();
|
||||
}
|
||||
|
||||
async addReplExpression(stackFrame: IStackFrame | undefined, name: string): Promise<void> {
|
||||
await this.repl.addReplExpression(this, stackFrame, name);
|
||||
async addReplExpression(stackFrame: IStackFrame | undefined, expression: string): Promise<void> {
|
||||
await this.repl.addReplExpression(this, stackFrame, expression);
|
||||
// Evaluate all watch expressions and fetch variables again since repl evaluation might have changed some.
|
||||
this.debugService.getViewModel().updateViews();
|
||||
}
|
||||
|
|
|
@ -472,6 +472,15 @@ export class Repl extends FilterViewPane implements IHistoryNavigationWidget {
|
|||
}
|
||||
}
|
||||
|
||||
sendReplInput(input: string): void {
|
||||
const session = this.tree?.getInput();
|
||||
if (session && !this.isReadonly) {
|
||||
session.addReplExpression(this.debugService.getViewModel().focusedStackFrame, input);
|
||||
revealLastElement(this.tree!);
|
||||
this.history.add(input);
|
||||
}
|
||||
}
|
||||
|
||||
getVisibleContent(): string {
|
||||
let text = '';
|
||||
if (this.model && this.tree) {
|
||||
|
|
|
@ -269,10 +269,10 @@ export class ReplModel {
|
|||
return this.replElements;
|
||||
}
|
||||
|
||||
async addReplExpression(session: IDebugSession, stackFrame: IStackFrame | undefined, name: string): Promise<void> {
|
||||
this.addReplElement(new ReplEvaluationInput(name));
|
||||
const result = new ReplEvaluationResult(name);
|
||||
await result.evaluateExpression(name, session, stackFrame, 'repl');
|
||||
async addReplExpression(session: IDebugSession, stackFrame: IStackFrame | undefined, expression: string): Promise<void> {
|
||||
this.addReplElement(new ReplEvaluationInput(expression));
|
||||
const result = new ReplEvaluationResult(expression);
|
||||
await result.evaluateExpression(expression, session, stackFrame, 'repl');
|
||||
this.addReplElement(result);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue