Skip to content

Commit 953d32c

Browse files
author
isidor
committed
debug: use asCannonicalUri when opening editors
microsoft#106382
1 parent fe66076 commit 953d32c

11 files changed

Lines changed: 38 additions & 20 deletions

File tree

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
3737
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
3838
import { Orientation } from 'vs/base/browser/ui/splitview/splitview';
3939
import { IListAccessibilityProvider } from 'vs/base/browser/ui/list/listWidget';
40+
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
4041

4142
const $ = dom.$;
4243

@@ -76,7 +77,8 @@ export class BreakpointsView extends ViewPane {
7677
@IContextKeyService contextKeyService: IContextKeyService,
7778
@IOpenerService openerService: IOpenerService,
7879
@ITelemetryService telemetryService: ITelemetryService,
79-
@ILabelService private readonly labelService: ILabelService
80+
@ILabelService private readonly labelService: ILabelService,
81+
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
8082
) {
8183
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
8284

@@ -133,7 +135,7 @@ export class BreakpointsView extends ViewPane {
133135
const element = this.list.element(e.element);
134136

135137
if (element instanceof Breakpoint) {
136-
openBreakpointSource(element, e.sideBySide, e.editorOptions.preserveFocus || false, this.debugService, this.editorService);
138+
openBreakpointSource(element, e.sideBySide, e.editorOptions.preserveFocus || false, this.debugService, this.editorService, this.uriIdentityService);
137139
}
138140
if (e.browserEvent instanceof MouseEvent && e.browserEvent.detail === 2 && element instanceof FunctionBreakpoint && element !== this.debugService.getViewModel().getSelectedFunctionBreakpoint()) {
139141
// double click
@@ -192,7 +194,7 @@ export class BreakpointsView extends ViewPane {
192194
if (element instanceof Breakpoint || element instanceof FunctionBreakpoint) {
193195
actions.push(new Action('workbench.action.debug.openEditorAndEditBreakpoint', nls.localize('editBreakpoint', "Edit {0}...", breakpointType), '', true, async () => {
194196
if (element instanceof Breakpoint) {
195-
const editor = await openBreakpointSource(element, false, false, this.debugService, this.editorService);
197+
const editor = await openBreakpointSource(element, false, false, this.debugService, this.editorService, this.uriIdentityService);
196198
if (editor) {
197199
const codeEditor = editor.getControl();
198200
if (isCodeEditor(codeEditor)) {
@@ -671,7 +673,7 @@ class BreakpointsAccessibilityProvider implements IListAccessibilityProvider<Bre
671673
}
672674
}
673675

674-
export function openBreakpointSource(breakpoint: IBreakpoint, sideBySide: boolean, preserveFocus: boolean, debugService: IDebugService, editorService: IEditorService): Promise<IEditorPane | undefined> {
676+
export function openBreakpointSource(breakpoint: IBreakpoint, sideBySide: boolean, preserveFocus: boolean, debugService: IDebugService, editorService: IEditorService, uriIdentityService: IUriIdentityService): Promise<IEditorPane | undefined> {
675677
if (breakpoint.uri.scheme === DEBUG_SCHEME && debugService.state === State.Inactive) {
676678
return Promise.resolve(undefined);
677679
}
@@ -689,7 +691,7 @@ export function openBreakpointSource(breakpoint: IBreakpoint, sideBySide: boolea
689691
};
690692

691693
return editorService.openEditor({
692-
resource: breakpoint.uri,
694+
resource: uriIdentityService.asCanonicalUri(breakpoint.uri),
693695
options: {
694696
preserveFocus,
695697
selection,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { posix } from 'vs/base/common/path';
4646
import { ITreeCompressionDelegate } from 'vs/base/browser/ui/tree/asyncDataTree';
4747
import { ICompressibleTreeRenderer } from 'vs/base/browser/ui/tree/objectTree';
4848
import { ICompressedTreeNode } from 'vs/base/browser/ui/tree/compressedObjectTreeModel';
49+
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
4950

5051
const $ = dom.$;
5152

@@ -138,6 +139,7 @@ export class CallStackView extends ViewPane {
138139
@IOpenerService openerService: IOpenerService,
139140
@IThemeService themeService: IThemeService,
140141
@ITelemetryService telemetryService: ITelemetryService,
142+
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
141143
) {
142144
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
143145
this.callStackItemType = CONTEXT_CALLSTACK_ITEM_TYPE.bindTo(contextKeyService);
@@ -289,7 +291,7 @@ export class CallStackView extends ViewPane {
289291
const element = e.element;
290292
if (element instanceof StackFrame) {
291293
focusStackFrame(element, element.thread, element.thread.session);
292-
element.openInEditor(this.editorService, e.editorOptions.preserveFocus, e.sideBySide, e.editorOptions.pinned);
294+
element.openInEditor(this.editorService, this.uriIdentityService, e.editorOptions.preserveFocus, e.sideBySide, e.editorOptions.pinned);
293295
}
294296
if (element instanceof Thread) {
295297
focusStackFrame(undefined, element, element.session);

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
1414
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
1515
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
1616
import { deepClone } from 'vs/base/common/objects';
17+
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
1718

1819
export abstract class AbstractDebugAction extends Action {
1920

@@ -369,7 +370,8 @@ export class FocusSessionAction extends AbstractDebugAction {
369370
constructor(id: string, label: string,
370371
@IDebugService debugService: IDebugService,
371372
@IKeybindingService keybindingService: IKeybindingService,
372-
@IEditorService private readonly editorService: IEditorService
373+
@IEditorService private readonly editorService: IEditorService,
374+
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
373375
) {
374376
super(id, label, '', debugService, keybindingService);
375377
}
@@ -378,7 +380,7 @@ export class FocusSessionAction extends AbstractDebugAction {
378380
await this.debugService.focusStackFrame(undefined, undefined, session, true);
379381
const stackFrame = this.debugService.getViewModel().focusedStackFrame;
380382
if (stackFrame) {
381-
await stackFrame.openInEditor(this.editorService, true);
383+
await stackFrame.openInEditor(this.editorService, this.uriIdentityService, true);
382384
}
383385
}
384386
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService
2929
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
3030
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
3131
import { IViewsService } from 'vs/workbench/common/views';
32+
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
3233

3334
export const ADD_CONFIGURATION_ID = 'debug.addConfiguration';
3435
export const TOGGLE_INLINE_BREAKPOINT_ID = 'editor.debug.action.toggleInlineBreakpoint';
@@ -564,7 +565,7 @@ export function registerCommands(): void {
564565
if (list instanceof List) {
565566
const focus = list.getFocusedElements();
566567
if (focus.length && focus[0] instanceof Breakpoint) {
567-
return openBreakpointSource(focus[0], true, false, accessor.get(IDebugService), accessor.get(IEditorService));
568+
return openBreakpointSource(focus[0], true, false, accessor.get(IDebugService), accessor.get(IEditorService), accessor.get(IUriIdentityService));
568569
}
569570
}
570571

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { IViewsService } from 'vs/workbench/common/views';
1919
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
2020
import { Action } from 'vs/base/common/actions';
2121
import { getDomNodePagePosition } from 'vs/base/browser/dom';
22+
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
2223

2324
export const TOGGLE_BREAKPOINT_ID = 'editor.debug.action.toggleBreakpoint';
2425
class ToggleBreakpointAction extends EditorAction {
@@ -305,6 +306,7 @@ class GoToBreakpointAction extends EditorAction {
305306
async run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<any> {
306307
const debugService = accessor.get(IDebugService);
307308
const editorService = accessor.get(IEditorService);
309+
const uriIdentityService = accessor.get(IUriIdentityService);
308310
if (editor.hasModel()) {
309311
const currentUri = editor.getModel().uri;
310312
const currentLine = editor.getPosition().lineNumber;
@@ -331,7 +333,7 @@ class GoToBreakpointAction extends EditorAction {
331333
}
332334

333335
if (moveBreakpoint) {
334-
return openBreakpointSource(moveBreakpoint, false, true, debugService, editorService);
336+
return openBreakpointSource(moveBreakpoint, false, true, debugService, editorService, uriIdentityService);
335337
}
336338
}
337339
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import { DebugTelemetry } from 'vs/workbench/contrib/debug/common/debugTelemetry
4848
import { DebugCompoundRoot } from 'vs/workbench/contrib/debug/common/debugCompoundRoot';
4949
import { ICommandService } from 'vs/platform/commands/common/commands';
5050
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
51+
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
5152

5253
export class DebugService implements IDebugService {
5354
declare readonly _serviceBrand: undefined;
@@ -92,7 +93,8 @@ export class DebugService implements IDebugService {
9293
@IExtensionHostDebugService private readonly extensionHostDebugService: IExtensionHostDebugService,
9394
@IActivityService private readonly activityService: IActivityService,
9495
@ICommandService private readonly commandService: ICommandService,
95-
@IQuickInputService private readonly quickInputService: IQuickInputService
96+
@IQuickInputService private readonly quickInputService: IQuickInputService,
97+
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
9698
) {
9799
this.toDispose = [];
98100

@@ -790,7 +792,7 @@ export class DebugService implements IDebugService {
790792
const { stackFrame, thread, session } = getStackFrameThreadAndSessionToFocus(this.model, _stackFrame, _thread, _session);
791793

792794
if (stackFrame) {
793-
const editor = await stackFrame.openInEditor(this.editorService, true);
795+
const editor = await stackFrame.openInEditor(this.editorService, this.uriIdentityService, true);
794796
if (editor) {
795797
const control = editor.getControl();
796798
if (stackFrame && isCodeEditor(control) && control.hasModel()) {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
3939
import { IThemeService } from 'vs/platform/theme/common/themeService';
4040
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
4141
import { IPathService } from 'vs/workbench/services/path/common/pathService';
42+
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
4243

4344
const NEW_STYLE_COMPRESS = true;
4445

@@ -432,6 +433,7 @@ export class LoadedScriptsView extends ViewPane {
432433
@IOpenerService openerService: IOpenerService,
433434
@IThemeService themeService: IThemeService,
434435
@ITelemetryService telemetryService: ITelemetryService,
436+
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
435437
) {
436438
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
437439
this.loadedScriptsItemType = CONTEXT_LOADED_SCRIPTS_ITEM_TYPE.bindTo(contextKeyService);
@@ -498,7 +500,7 @@ export class LoadedScriptsView extends ViewPane {
498500
const source = e.element.getSource();
499501
if (source && source.available) {
500502
const nullRange = { startLineNumber: 0, startColumn: 0, endLineNumber: 0, endColumn: 0 };
501-
source.openInEditor(this.editorService, nullRange, e.editorOptions.preserveFocus, e.sideBySide, e.editorOptions.pinned);
503+
source.openInEditor(this.editorService, this.uriIdentityService, nullRange, e.editorOptions.preserveFocus, e.sideBySide, e.editorOptions.pinned);
502504
}
503505
}
504506
}));

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { IReplElementSource, IDebugService, IExpression, IReplElement, IDebugCon
2323
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
2424
import { IThemeService } from 'vs/platform/theme/common/themeService';
2525
import { localize } from 'vs/nls';
26+
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
2627

2728
const $ = dom.$;
2829

@@ -138,7 +139,8 @@ export class ReplSimpleElementsRenderer implements ITreeRenderer<SimpleReplEleme
138139
private readonly linkDetector: LinkDetector,
139140
@IEditorService private readonly editorService: IEditorService,
140141
@ILabelService private readonly labelService: ILabelService,
141-
@IThemeService private readonly themeService: IThemeService
142+
@IThemeService private readonly themeService: IThemeService,
143+
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
142144
) { }
143145

144146
get templateId(): string {
@@ -159,7 +161,7 @@ export class ReplSimpleElementsRenderer implements ITreeRenderer<SimpleReplEleme
159161
e.stopPropagation();
160162
const source = data.getReplElementSource();
161163
if (source) {
162-
source.source.openInEditor(this.editorService, {
164+
source.source.openInEditor(this.editorService, this.uriIdentityService, {
163165
startLineNumber: source.lineNumber,
164166
startColumn: source.column,
165167
endLineNumber: source.lineNumber,

src/vs/workbench/contrib/debug/common/debug.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
2525
import { CancellationToken } from 'vs/base/common/cancellation';
2626
import { DebugConfigurationProviderTriggerKind } from 'vs/workbench/api/common/extHostTypes';
2727
import { DebugCompoundRoot } from 'vs/workbench/contrib/debug/common/debugCompoundRoot';
28+
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
2829

2930
export const VIEWLET_ID = 'workbench.view.debug';
3031

@@ -347,7 +348,7 @@ export interface IStackFrame extends ITreeElement {
347348
forgetScopes(): void;
348349
restart(): Promise<any>;
349350
toString(): string;
350-
openInEditor(editorService: IEditorService, preserveFocus?: boolean, sideBySide?: boolean): Promise<ITextEditorPane | undefined>;
351+
openInEditor(editorService: IEditorService, uriIdentityService: IUriIdentityService, preserveFocus?: boolean, sideBySide?: boolean): Promise<ITextEditorPane | undefined>;
351352
equals(other: IStackFrame): boolean;
352353
}
353354

src/vs/workbench/contrib/debug/common/debugModel.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { ITextEditorPane } from 'vs/workbench/common/editor';
2323
import { mixin } from 'vs/base/common/objects';
2424
import { DebugStorage } from 'vs/workbench/contrib/debug/common/debugStorage';
2525
import { CancellationTokenSource } from 'vs/base/common/cancellation';
26+
import { IUriIdentityService } from 'vs/workbench/services/uriIdentity/common/uriIdentity';
2627

2728
interface IDebugProtocolVariableWithContext extends DebugProtocol.Variable {
2829
__vscodeVariableMenuContext?: string;
@@ -374,9 +375,9 @@ export class StackFrame implements IStackFrame {
374375
return sourceToString === UNKNOWN_SOURCE_LABEL ? this.name : `${this.name} (${sourceToString})`;
375376
}
376377

377-
async openInEditor(editorService: IEditorService, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise<ITextEditorPane | undefined> {
378+
async openInEditor(editorService: IEditorService, uriIdentityService: IUriIdentityService, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise<ITextEditorPane | undefined> {
378379
if (this.source.available) {
379-
return this.source.openInEditor(editorService, this.range, preserveFocus, sideBySide, pinned);
380+
return this.source.openInEditor(editorService, uriIdentityService, this.range, preserveFocus, sideBySide, pinned);
380381
}
381382
return undefined;
382383
}

0 commit comments

Comments
 (0)