提交 953d32c4 编写于 作者: I isidor

debug: use asCannonicalUri when opening editors

#106382
上级 fe660760
......@@ -37,6 +37,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { Orientation } from 'vs/base/browser/ui/splitview/splitview';
import { IListAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
const $ = dom.$;
......@@ -76,7 +77,8 @@ export class BreakpointsView extends ViewPane {
@IContextKeyService contextKeyService: IContextKeyService,
@IOpenerService openerService: IOpenerService,
@ITelemetryService telemetryService: ITelemetryService,
@ILabelService private readonly labelService: ILabelService
@ILabelService private readonly labelService: ILabelService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
......@@ -133,7 +135,7 @@ export class BreakpointsView extends ViewPane {
const element = this.list.element(e.element);
if (element instanceof Breakpoint) {
openBreakpointSource(element, e.sideBySide, e.editorOptions.preserveFocus || false, this.debugService, this.editorService);
openBreakpointSource(element, e.sideBySide, e.editorOptions.preserveFocus || false, this.debugService, this.editorService, this.uriIdentityService);
}
if (e.browserEvent instanceof MouseEvent && e.browserEvent.detail === 2 && element instanceof FunctionBreakpoint && element !== this.debugService.getViewModel().getSelectedFunctionBreakpoint()) {
// double click
......@@ -192,7 +194,7 @@ export class BreakpointsView extends ViewPane {
if (element instanceof Breakpoint || element instanceof FunctionBreakpoint) {
actions.push(new Action('workbench.action.debug.openEditorAndEditBreakpoint', nls.localize('editBreakpoint', "Edit {0}...", breakpointType), '', true, async () => {
if (element instanceof Breakpoint) {
const editor = await openBreakpointSource(element, false, false, this.debugService, this.editorService);
const editor = await openBreakpointSource(element, false, false, this.debugService, this.editorService, this.uriIdentityService);
if (editor) {
const codeEditor = editor.getControl();
if (isCodeEditor(codeEditor)) {
......@@ -671,7 +673,7 @@ class BreakpointsAccessibilityProvider implements IListAccessibilityProvider<Bre
}
}
export function openBreakpointSource(breakpoint: IBreakpoint, sideBySide: boolean, preserveFocus: boolean, debugService: IDebugService, editorService: IEditorService): Promise<IEditorPane | undefined> {
export function openBreakpointSource(breakpoint: IBreakpoint, sideBySide: boolean, preserveFocus: boolean, debugService: IDebugService, editorService: IEditorService, uriIdentityService: IUriIdentityService): Promise<IEditorPane | undefined> {
if (breakpoint.uri.scheme === DEBUG_SCHEME && debugService.state === State.Inactive) {
return Promise.resolve(undefined);
}
......@@ -689,7 +691,7 @@ export function openBreakpointSource(breakpoint: IBreakpoint, sideBySide: boolea
};
return editorService.openEditor({
resource: breakpoint.uri,
resource: uriIdentityService.asCanonicalUri(breakpoint.uri),
options: {
preserveFocus,
selection,
......
......@@ -46,6 +46,7 @@ import { posix } from 'vs/base/common/path';
import { ITreeCompressionDelegate } from 'vs/base/browser/ui/tree/asyncDataTree';
import { ICompressibleTreeRenderer } from 'vs/base/browser/ui/tree/objectTree';
import { ICompressedTreeNode } from 'vs/base/browser/ui/tree/compressedObjectTreeModel';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
const $ = dom.$;
......@@ -138,6 +139,7 @@ export class CallStackView extends ViewPane {
@IOpenerService openerService: IOpenerService,
@IThemeService themeService: IThemeService,
@ITelemetryService telemetryService: ITelemetryService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
this.callStackItemType = CONTEXT_CALLSTACK_ITEM_TYPE.bindTo(contextKeyService);
......@@ -289,7 +291,7 @@ export class CallStackView extends ViewPane {
const element = e.element;
if (element instanceof StackFrame) {
focusStackFrame(element, element.thread, element.thread.session);
element.openInEditor(this.editorService, e.editorOptions.preserveFocus, e.sideBySide, e.editorOptions.pinned);
element.openInEditor(this.editorService, this.uriIdentityService, e.editorOptions.preserveFocus, e.sideBySide, e.editorOptions.pinned);
}
if (element instanceof Thread) {
focusStackFrame(undefined, element, element.session);
......
......@@ -14,6 +14,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { deepClone } from 'vs/base/common/objects';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
export abstract class AbstractDebugAction extends Action {
......@@ -369,7 +370,8 @@ export class FocusSessionAction extends AbstractDebugAction {
constructor(id: string, label: string,
@IDebugService debugService: IDebugService,
@IKeybindingService keybindingService: IKeybindingService,
@IEditorService private readonly editorService: IEditorService
@IEditorService private readonly editorService: IEditorService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
) {
super(id, label, '', debugService, keybindingService);
}
......@@ -378,7 +380,7 @@ export class FocusSessionAction extends AbstractDebugAction {
await this.debugService.focusStackFrame(undefined, undefined, session, true);
const stackFrame = this.debugService.getViewModel().focusedStackFrame;
if (stackFrame) {
await stackFrame.openInEditor(this.editorService, true);
await stackFrame.openInEditor(this.editorService, this.uriIdentityService, true);
}
}
}
......
......@@ -29,6 +29,7 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { IViewsService } from 'vs/workbench/common/views';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
export const ADD_CONFIGURATION_ID = 'debug.addConfiguration';
export const TOGGLE_INLINE_BREAKPOINT_ID = 'editor.debug.action.toggleInlineBreakpoint';
......@@ -564,7 +565,7 @@ export function registerCommands(): void {
if (list instanceof List) {
const focus = list.getFocusedElements();
if (focus.length && focus[0] instanceof Breakpoint) {
return openBreakpointSource(focus[0], true, false, accessor.get(IDebugService), accessor.get(IEditorService));
return openBreakpointSource(focus[0], true, false, accessor.get(IDebugService), accessor.get(IEditorService), accessor.get(IUriIdentityService));
}
}
......
......@@ -19,6 +19,7 @@ import { IViewsService } from 'vs/workbench/common/views';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { Action } from 'vs/base/common/actions';
import { getDomNodePagePosition } from 'vs/base/browser/dom';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
export const TOGGLE_BREAKPOINT_ID = 'editor.debug.action.toggleBreakpoint';
class ToggleBreakpointAction extends EditorAction {
......@@ -305,6 +306,7 @@ class GoToBreakpointAction extends EditorAction {
async run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<any> {
const debugService = accessor.get(IDebugService);
const editorService = accessor.get(IEditorService);
const uriIdentityService = accessor.get(IUriIdentityService);
if (editor.hasModel()) {
const currentUri = editor.getModel().uri;
const currentLine = editor.getPosition().lineNumber;
......@@ -331,7 +333,7 @@ class GoToBreakpointAction extends EditorAction {
}
if (moveBreakpoint) {
return openBreakpointSource(moveBreakpoint, false, true, debugService, editorService);
return openBreakpointSource(moveBreakpoint, false, true, debugService, editorService, uriIdentityService);
}
}
}
......
......@@ -48,6 +48,7 @@ import { DebugTelemetry } from 'vs/workbench/contrib/debug/common/debugTelemetry
import { DebugCompoundRoot } from 'vs/workbench/contrib/debug/common/debugCompoundRoot';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
export class DebugService implements IDebugService {
declare readonly _serviceBrand: undefined;
......@@ -92,7 +93,8 @@ export class DebugService implements IDebugService {
@IExtensionHostDebugService private readonly extensionHostDebugService: IExtensionHostDebugService,
@IActivityService private readonly activityService: IActivityService,
@ICommandService private readonly commandService: ICommandService,
@IQuickInputService private readonly quickInputService: IQuickInputService
@IQuickInputService private readonly quickInputService: IQuickInputService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
) {
this.toDispose = [];
......@@ -790,7 +792,7 @@ export class DebugService implements IDebugService {
const { stackFrame, thread, session } = getStackFrameThreadAndSessionToFocus(this.model, _stackFrame, _thread, _session);
if (stackFrame) {
const editor = await stackFrame.openInEditor(this.editorService, true);
const editor = await stackFrame.openInEditor(this.editorService, this.uriIdentityService, true);
if (editor) {
const control = editor.getControl();
if (stackFrame && isCodeEditor(control) && control.hasModel()) {
......
......@@ -39,6 +39,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IPathService } from 'vs/workbench/services/path/common/pathService';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
const NEW_STYLE_COMPRESS = true;
......@@ -432,6 +433,7 @@ export class LoadedScriptsView extends ViewPane {
@IOpenerService openerService: IOpenerService,
@IThemeService themeService: IThemeService,
@ITelemetryService telemetryService: ITelemetryService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
) {
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
this.loadedScriptsItemType = CONTEXT_LOADED_SCRIPTS_ITEM_TYPE.bindTo(contextKeyService);
......@@ -498,7 +500,7 @@ export class LoadedScriptsView extends ViewPane {
const source = e.element.getSource();
if (source && source.available) {
const nullRange = { startLineNumber: 0, startColumn: 0, endLineNumber: 0, endColumn: 0 };
source.openInEditor(this.editorService, nullRange, e.editorOptions.preserveFocus, e.sideBySide, e.editorOptions.pinned);
source.openInEditor(this.editorService, this.uriIdentityService, nullRange, e.editorOptions.preserveFocus, e.sideBySide, e.editorOptions.pinned);
}
}
}));
......
......@@ -23,6 +23,7 @@ import { IReplElementSource, IDebugService, IExpression, IReplElement, IDebugCon
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { localize } from 'vs/nls';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
const $ = dom.$;
......@@ -138,7 +139,8 @@ export class ReplSimpleElementsRenderer implements ITreeRenderer<SimpleReplEleme
private readonly linkDetector: LinkDetector,
@IEditorService private readonly editorService: IEditorService,
@ILabelService private readonly labelService: ILabelService,
@IThemeService private readonly themeService: IThemeService
@IThemeService private readonly themeService: IThemeService,
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
) { }
get templateId(): string {
......@@ -159,7 +161,7 @@ export class ReplSimpleElementsRenderer implements ITreeRenderer<SimpleReplEleme
e.stopPropagation();
const source = data.getReplElementSource();
if (source) {
source.source.openInEditor(this.editorService, {
source.source.openInEditor(this.editorService, this.uriIdentityService, {
startLineNumber: source.lineNumber,
startColumn: source.column,
endLineNumber: source.lineNumber,
......
......@@ -25,6 +25,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { CancellationToken } from 'vs/base/common/cancellation';
import { DebugConfigurationProviderTriggerKind } from 'vs/workbench/api/common/extHostTypes';
import { DebugCompoundRoot } from 'vs/workbench/contrib/debug/common/debugCompoundRoot';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
export const VIEWLET_ID = 'workbench.view.debug';
......@@ -347,7 +348,7 @@ export interface IStackFrame extends ITreeElement {
forgetScopes(): void;
restart(): Promise<any>;
toString(): string;
openInEditor(editorService: IEditorService, preserveFocus?: boolean, sideBySide?: boolean): Promise<ITextEditorPane | undefined>;
openInEditor(editorService: IEditorService, uriIdentityService: IUriIdentityService, preserveFocus?: boolean, sideBySide?: boolean): Promise<ITextEditorPane | undefined>;
equals(other: IStackFrame): boolean;
}
......
......@@ -23,6 +23,7 @@ import { ITextEditorPane } from 'vs/workbench/common/editor';
import { mixin } from 'vs/base/common/objects';
import { DebugStorage } from 'vs/workbench/contrib/debug/common/debugStorage';
import { CancellationTokenSource } from 'vs/base/common/cancellation';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
interface IDebugProtocolVariableWithContext extends DebugProtocol.Variable {
__vscodeVariableMenuContext?: string;
......@@ -374,9 +375,9 @@ export class StackFrame implements IStackFrame {
return sourceToString === UNKNOWN_SOURCE_LABEL ? this.name : `${this.name} (${sourceToString})`;
}
async openInEditor(editorService: IEditorService, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise<ITextEditorPane | undefined> {
async openInEditor(editorService: IEditorService, uriIdentityService: IUriIdentityService, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise<ITextEditorPane | undefined> {
if (this.source.available) {
return this.source.openInEditor(editorService, this.range, preserveFocus, sideBySide, pinned);
return this.source.openInEditor(editorService, uriIdentityService, this.range, preserveFocus, sideBySide, pinned);
}
return undefined;
}
......
......@@ -14,6 +14,7 @@ import { Schemas } from 'vs/base/common/network';
import { isUri } from 'vs/workbench/contrib/debug/common/debugUtils';
import { ITextEditorPane } from 'vs/workbench/common/editor';
import { TextEditorSelectionRevealType } from 'vs/platform/editor/common/editor';
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
export const UNKNOWN_SOURCE_LABEL = nls.localize('unknownSource', "Unknown Source");
......@@ -71,9 +72,9 @@ export class Source {
return this.uri.scheme === DEBUG_SCHEME;
}
openInEditor(editorService: IEditorService, selection: IRange, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise<ITextEditorPane | undefined> {
openInEditor(editorService: IEditorService, uriIdentityService: IUriIdentityService, selection: IRange, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise<ITextEditorPane | undefined> {
return !this.available ? Promise.resolve(undefined) : editorService.openEditor({
resource: this.uri,
resource: uriIdentityService.asCanonicalUri(this.uri),
description: this.origin,
options: {
preserveFocus,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册