From 953d32c4e253e3bedfd888e3b50f9656c7446a73 Mon Sep 17 00:00:00 2001 From: isidor Date: Wed, 16 Sep 2020 16:03:10 +0200 Subject: [PATCH] debug: use asCannonicalUri when opening editors #106382 --- .../contrib/debug/browser/breakpointsView.ts | 12 +++++++----- .../workbench/contrib/debug/browser/callStackView.ts | 4 +++- .../workbench/contrib/debug/browser/debugActions.ts | 6 ++++-- .../workbench/contrib/debug/browser/debugCommands.ts | 3 ++- .../contrib/debug/browser/debugEditorActions.ts | 4 +++- .../workbench/contrib/debug/browser/debugService.ts | 6 ++++-- .../contrib/debug/browser/loadedScriptsView.ts | 4 +++- src/vs/workbench/contrib/debug/browser/replViewer.ts | 6 ++++-- src/vs/workbench/contrib/debug/common/debug.ts | 3 ++- src/vs/workbench/contrib/debug/common/debugModel.ts | 5 +++-- src/vs/workbench/contrib/debug/common/debugSource.ts | 5 +++-- 11 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/vs/workbench/contrib/debug/browser/breakpointsView.ts b/src/vs/workbench/contrib/debug/browser/breakpointsView.ts index 188205abf49..060c4a64229 100644 --- a/src/vs/workbench/contrib/debug/browser/breakpointsView.ts +++ b/src/vs/workbench/contrib/debug/browser/breakpointsView.ts @@ -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 { +export function openBreakpointSource(breakpoint: IBreakpoint, sideBySide: boolean, preserveFocus: boolean, debugService: IDebugService, editorService: IEditorService, uriIdentityService: IUriIdentityService): Promise { 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, diff --git a/src/vs/workbench/contrib/debug/browser/callStackView.ts b/src/vs/workbench/contrib/debug/browser/callStackView.ts index 83c99e79306..2acdb87e77f 100644 --- a/src/vs/workbench/contrib/debug/browser/callStackView.ts +++ b/src/vs/workbench/contrib/debug/browser/callStackView.ts @@ -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); diff --git a/src/vs/workbench/contrib/debug/browser/debugActions.ts b/src/vs/workbench/contrib/debug/browser/debugActions.ts index 3f3e09c959a..ead80a45b2b 100644 --- a/src/vs/workbench/contrib/debug/browser/debugActions.ts +++ b/src/vs/workbench/contrib/debug/browser/debugActions.ts @@ -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); } } } diff --git a/src/vs/workbench/contrib/debug/browser/debugCommands.ts b/src/vs/workbench/contrib/debug/browser/debugCommands.ts index d857ef4326b..a7fff262b3e 100644 --- a/src/vs/workbench/contrib/debug/browser/debugCommands.ts +++ b/src/vs/workbench/contrib/debug/browser/debugCommands.ts @@ -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)); } } diff --git a/src/vs/workbench/contrib/debug/browser/debugEditorActions.ts b/src/vs/workbench/contrib/debug/browser/debugEditorActions.ts index e6b08a505c5..e5c0f68206f 100644 --- a/src/vs/workbench/contrib/debug/browser/debugEditorActions.ts +++ b/src/vs/workbench/contrib/debug/browser/debugEditorActions.ts @@ -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 { 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); } } } diff --git a/src/vs/workbench/contrib/debug/browser/debugService.ts b/src/vs/workbench/contrib/debug/browser/debugService.ts index c040680bcc2..9e5943cf2d5 100644 --- a/src/vs/workbench/contrib/debug/browser/debugService.ts +++ b/src/vs/workbench/contrib/debug/browser/debugService.ts @@ -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()) { diff --git a/src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts b/src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts index 2181397cc60..f4c0157ed1e 100644 --- a/src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts +++ b/src/vs/workbench/contrib/debug/browser/loadedScriptsView.ts @@ -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); } } })); diff --git a/src/vs/workbench/contrib/debug/browser/replViewer.ts b/src/vs/workbench/contrib/debug/browser/replViewer.ts index 4fbb33ebc60..e98704a8a22 100644 --- a/src/vs/workbench/contrib/debug/browser/replViewer.ts +++ b/src/vs/workbench/contrib/debug/browser/replViewer.ts @@ -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; toString(): string; - openInEditor(editorService: IEditorService, preserveFocus?: boolean, sideBySide?: boolean): Promise; + openInEditor(editorService: IEditorService, uriIdentityService: IUriIdentityService, preserveFocus?: boolean, sideBySide?: boolean): Promise; equals(other: IStackFrame): boolean; } diff --git a/src/vs/workbench/contrib/debug/common/debugModel.ts b/src/vs/workbench/contrib/debug/common/debugModel.ts index a76c411801f..134beff8ae1 100644 --- a/src/vs/workbench/contrib/debug/common/debugModel.ts +++ b/src/vs/workbench/contrib/debug/common/debugModel.ts @@ -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 { + async openInEditor(editorService: IEditorService, uriIdentityService: IUriIdentityService, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise { 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; } diff --git a/src/vs/workbench/contrib/debug/common/debugSource.ts b/src/vs/workbench/contrib/debug/common/debugSource.ts index c16cf5295ee..5130be0d148 100644 --- a/src/vs/workbench/contrib/debug/common/debugSource.ts +++ b/src/vs/workbench/contrib/debug/common/debugSource.ts @@ -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 { + openInEditor(editorService: IEditorService, uriIdentityService: IUriIdentityService, selection: IRange, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise { return !this.available ? Promise.resolve(undefined) : editorService.openEditor({ - resource: this.uri, + resource: uriIdentityService.asCanonicalUri(this.uri), description: this.origin, options: { preserveFocus, -- GitLab