Skip to content

Commit 0163082

Browse files
committed
use label service for breakpoint path in breakpoints view
microsoft#100475
1 parent 694abe2 commit 0163082

3 files changed

Lines changed: 26 additions & 17 deletions

File tree

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { BrowserFeatures } from 'vs/base/browser/canIUse';
3535
import { isSafari } from 'vs/base/browser/browser';
3636
import { registerThemingParticipant } from 'vs/platform/theme/common/themeService';
3737
import { registerColor } from 'vs/platform/theme/common/colorRegistry';
38+
import { ILabelService } from 'vs/platform/label/common/label';
3839

3940
const $ = dom.$;
4041

@@ -72,7 +73,7 @@ export function createBreakpointDecorations(model: ITextModel, breakpoints: Read
7273
}
7374

7475
function getBreakpointDecorationOptions(model: ITextModel, breakpoint: IBreakpoint, state: State, breakpointsActivated: boolean, showBreakpointsInOverviewRuler: boolean): IModelDecorationOptions {
75-
const { className, message } = getBreakpointMessageAndClassName(state, breakpointsActivated, breakpoint);
76+
const { className, message } = getBreakpointMessageAndClassName(state, breakpointsActivated, breakpoint, undefined);
7677
let glyphMarginHoverMessage: MarkdownString | undefined;
7778

7879
if (message) {
@@ -163,7 +164,8 @@ export class BreakpointEditorContribution implements IBreakpointEditorContributi
163164
@IInstantiationService private readonly instantiationService: IInstantiationService,
164165
@IContextKeyService contextKeyService: IContextKeyService,
165166
@IDialogService private readonly dialogService: IDialogService,
166-
@IConfigurationService private readonly configurationService: IConfigurationService
167+
@IConfigurationService private readonly configurationService: IConfigurationService,
168+
@ILabelService private readonly labelService: ILabelService
167169
) {
168170
this.breakpointWidgetVisible = CONTEXT_BREAKPOINT_WIDGET_VISIBLE.bindTo(contextKeyService);
169171
this.registerListeners();
@@ -443,7 +445,7 @@ export class BreakpointEditorContribution implements IBreakpointEditorContributi
443445
// Candidate decoration has a breakpoint attached when a breakpoint is already at that location and we did not yet set a decoration there
444446
// In practice this happens for the first breakpoint that was set on a line
445447
// We could have also rendered this first decoration as part of desiredBreakpointDecorations however at that moment we have no location information
446-
const cssClass = candidate.breakpoint ? getBreakpointMessageAndClassName(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), candidate.breakpoint).className : 'codicon-debug-breakpoint-disabled';
448+
const cssClass = candidate.breakpoint ? getBreakpointMessageAndClassName(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), candidate.breakpoint, this.labelService).className : 'codicon-debug-breakpoint-disabled';
447449
const contextMenuActions = () => this.getContextMenuActions(candidate.breakpoint ? [candidate.breakpoint] : [], activeCodeEditor.getModel().uri, candidate.range.startLineNumber, candidate.range.startColumn);
448450
const inlineWidget = new InlineBreakpointWidget(activeCodeEditor, decorationId, cssClass, candidate.breakpoint, this.debugService, this.contextMenuService, contextMenuActions);
449451

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

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export class BreakpointsView extends ViewPane {
7777
@IContextKeyService contextKeyService: IContextKeyService,
7878
@IOpenerService openerService: IOpenerService,
7979
@ITelemetryService telemetryService: ITelemetryService,
80+
@ILabelService private readonly labelService: ILabelService
8081
) {
8182
super(options, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService, telemetryService);
8283

@@ -95,12 +96,12 @@ export class BreakpointsView extends ViewPane {
9596
new ExceptionBreakpointsRenderer(this.debugService),
9697
this.instantiationService.createInstance(FunctionBreakpointsRenderer),
9798
this.instantiationService.createInstance(DataBreakpointsRenderer),
98-
new FunctionBreakpointInputRenderer(this.debugService, this.contextViewService, this.themeService)
99+
new FunctionBreakpointInputRenderer(this.debugService, this.contextViewService, this.themeService, this.labelService)
99100
], {
100101
identityProvider: { getId: (element: IEnablement) => element.getId() },
101102
multipleSelectionSupport: false,
102103
keyboardNavigationLabelProvider: { getKeyboardNavigationLabel: (e: IEnablement) => e },
103-
accessibilityProvider: new BreakpointsAccessibilityProvider(this.debugService),
104+
accessibilityProvider: new BreakpointsAccessibilityProvider(this.debugService, this.labelService),
104105
overrideStyles: {
105106
listBackground: this.getBackgroundColor()
106107
}
@@ -379,7 +380,7 @@ class BreakpointsRenderer implements IListRenderer<IBreakpoint, IBreakpointTempl
379380
data.filePath.textContent = this.labelService.getUriLabel(resources.dirname(breakpoint.uri), { relative: true });
380381
data.checkbox.checked = breakpoint.enabled;
381382

382-
const { message, className } = getBreakpointMessageAndClassName(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), breakpoint);
383+
const { message, className } = getBreakpointMessageAndClassName(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), breakpoint, this.labelService);
383384
data.icon.className = `codicon ${className}`;
384385
data.breakpoint.title = breakpoint.message || message || '';
385386

@@ -441,7 +442,8 @@ class ExceptionBreakpointsRenderer implements IListRenderer<IExceptionBreakpoint
441442
class FunctionBreakpointsRenderer implements IListRenderer<FunctionBreakpoint, IBaseBreakpointWithIconTemplateData> {
442443

443444
constructor(
444-
@IDebugService private readonly debugService: IDebugService
445+
@IDebugService private readonly debugService: IDebugService,
446+
@ILabelService private readonly labelService: ILabelService
445447
) {
446448
// noop
447449
}
@@ -474,7 +476,7 @@ class FunctionBreakpointsRenderer implements IListRenderer<FunctionBreakpoint, I
474476
renderElement(functionBreakpoint: FunctionBreakpoint, _index: number, data: IBaseBreakpointWithIconTemplateData): void {
475477
data.context = functionBreakpoint;
476478
data.name.textContent = functionBreakpoint.name;
477-
const { className, message } = getBreakpointMessageAndClassName(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), functionBreakpoint);
479+
const { className, message } = getBreakpointMessageAndClassName(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), functionBreakpoint, this.labelService);
478480
data.icon.className = `codicon ${className}`;
479481
data.icon.title = message ? message : '';
480482
data.checkbox.checked = functionBreakpoint.enabled;
@@ -496,7 +498,8 @@ class FunctionBreakpointsRenderer implements IListRenderer<FunctionBreakpoint, I
496498
class DataBreakpointsRenderer implements IListRenderer<DataBreakpoint, IBaseBreakpointWithIconTemplateData> {
497499

498500
constructor(
499-
@IDebugService private readonly debugService: IDebugService
501+
@IDebugService private readonly debugService: IDebugService,
502+
@ILabelService private readonly labelService: ILabelService
500503
) {
501504
// noop
502505
}
@@ -529,7 +532,7 @@ class DataBreakpointsRenderer implements IListRenderer<DataBreakpoint, IBaseBrea
529532
renderElement(dataBreakpoint: DataBreakpoint, _index: number, data: IBaseBreakpointWithIconTemplateData): void {
530533
data.context = dataBreakpoint;
531534
data.name.textContent = dataBreakpoint.description;
532-
const { className, message } = getBreakpointMessageAndClassName(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), dataBreakpoint);
535+
const { className, message } = getBreakpointMessageAndClassName(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), dataBreakpoint, this.labelService);
533536
data.icon.className = `codicon ${className}`;
534537
data.icon.title = message ? message : '';
535538
data.checkbox.checked = dataBreakpoint.enabled;
@@ -553,7 +556,8 @@ class FunctionBreakpointInputRenderer implements IListRenderer<IFunctionBreakpoi
553556
constructor(
554557
private debugService: IDebugService,
555558
private contextViewService: IContextViewService,
556-
private themeService: IThemeService
559+
private themeService: IThemeService,
560+
private labelService: ILabelService
557561
) {
558562
// noop
559563
}
@@ -619,7 +623,7 @@ class FunctionBreakpointInputRenderer implements IListRenderer<IFunctionBreakpoi
619623
renderElement(functionBreakpoint: FunctionBreakpoint, _index: number, data: IInputTemplateData): void {
620624
data.breakpoint = functionBreakpoint;
621625
data.reactedOnEvent = false;
622-
const { className, message } = getBreakpointMessageAndClassName(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), functionBreakpoint);
626+
const { className, message } = getBreakpointMessageAndClassName(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), functionBreakpoint, this.labelService);
623627

624628
data.icon.className = `codicon ${className}`;
625629
data.icon.title = message ? message : '';
@@ -639,7 +643,10 @@ class FunctionBreakpointInputRenderer implements IListRenderer<IFunctionBreakpoi
639643

640644
class BreakpointsAccessibilityProvider implements IListAccessibilityProvider<BreakpointItem> {
641645

642-
constructor(private readonly debugService: IDebugService) { }
646+
constructor(
647+
private readonly debugService: IDebugService,
648+
private readonly labelService: ILabelService
649+
) { }
643650

644651
getWidgetAriaLabel(): string {
645652
return nls.localize('breakpoints', "Breakpoints");
@@ -658,7 +665,7 @@ class BreakpointsAccessibilityProvider implements IListAccessibilityProvider<Bre
658665
return element.toString();
659666
}
660667

661-
const { message } = getBreakpointMessageAndClassName(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), element as IBreakpoint | IDataBreakpoint | IFunctionBreakpoint);
668+
const { message } = getBreakpointMessageAndClassName(this.debugService.state, this.debugService.getModel().areBreakpointsActivated(), element as IBreakpoint | IDataBreakpoint | IFunctionBreakpoint, this.labelService);
662669
const toString = element.toString();
663670

664671
return message ? `${toString}, ${message}` : toString;
@@ -694,7 +701,7 @@ export function openBreakpointSource(breakpoint: IBreakpoint, sideBySide: boolea
694701
}, sideBySide ? SIDE_GROUP : ACTIVE_GROUP);
695702
}
696703

697-
export function getBreakpointMessageAndClassName(state: State, breakpointsActivated: boolean, breakpoint: IBreakpoint | IFunctionBreakpoint | IDataBreakpoint): { message?: string, className: string } {
704+
export function getBreakpointMessageAndClassName(state: State, breakpointsActivated: boolean, breakpoint: IBreakpoint | IFunctionBreakpoint | IDataBreakpoint, labelService?: ILabelService): { message?: string, className: string } {
698705
const debugActive = state === State.Running || state === State.Stopped;
699706

700707
if (!breakpoint.enabled || !breakpointsActivated) {
@@ -768,7 +775,7 @@ export function getBreakpointMessageAndClassName(state: State, breakpointsActiva
768775
};
769776
}
770777

771-
const message = ('message' in breakpoint && breakpoint.message) ? breakpoint.message : breakpoint instanceof Breakpoint ? breakpoint.uri.path : nls.localize('breakpoint', "Breakpoint");
778+
const message = ('message' in breakpoint && breakpoint.message) ? breakpoint.message : breakpoint instanceof Breakpoint && labelService ? labelService.getUriLabel(breakpoint.uri) : nls.localize('breakpoint', "Breakpoint");
772779
return {
773780
className: 'codicon-debug-breakpoint',
774781
message

src/vs/workbench/contrib/debug/test/browser/breakpoints.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ suite('Debug - Breakpoints', () => {
281281
assert.equal(result.className, 'codicon-debug-breakpoint-conditional');
282282

283283
result = getBreakpointMessageAndClassName(State.Stopped, true, breakpoints[4]);
284-
assert.equal(result.message, '/myfolder/my file first.js');
284+
assert.equal(result.message, 'Breakpoint');
285285
assert.equal(result.className, 'codicon-debug-breakpoint');
286286

287287
result = getBreakpointMessageAndClassName(State.Stopped, false, breakpoints[2]);

0 commit comments

Comments
 (0)