Skip to content

Commit de6741a

Browse files
committed
fix copilot issues
1 parent 2d03b3a commit de6741a

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

src/vs/workbench/api/browser/mainThreadCustomEditorOutline.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ export class MainThreadCustomEditorOutline extends Disposable implements MainThr
145145
}
146146

147147
$unregisterCustomEditorOutlineProvider(viewType: string): void {
148+
// deleteAndDispose disposes the registration returned by registerProvider(),
149+
// whose dispose handler already removes the entry and fires onDidChange.
148150
this._registrations.deleteAndDispose(viewType);
149-
this._service.unregisterProvider(viewType);
150151
}
151152

152153
$onDidChangeOutline(viewType: string): void {

src/vs/workbench/contrib/customEditor/browser/customEditorOutline.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class CustomEditorOutlineRenderer implements ITreeRenderer<CustomEditorOutlineEn
7575
@IContextKeyService private readonly _contextKeyService: IContextKeyService,
7676
@IMenuService private readonly _menuService: IMenuService,
7777
@IInstantiationService private readonly _instantiationService: IInstantiationService,
78+
@IConfigurationService private readonly _configurationService: IConfigurationService,
7879
) { }
7980

8081
renderTemplate(container: HTMLElement): ICustomEditorOutlineTemplate {
@@ -98,10 +99,13 @@ class CustomEditorOutlineRenderer implements ITreeRenderer<CustomEditorOutlineEn
9899

99100
template.iconClass.className = '';
100101
template.iconClass.classList.add('outline-element-icon', 'inline');
101-
if (entry.icon) {
102+
if (entry.icon && this._configurationService.getValue<boolean>(OutlineConfigKeys.icons)) {
102103
template.iconClass.classList.add('codicon-colored', ...ThemeIcon.asClassNameArray(entry.icon));
103104
}
104105

106+
if (entry.tooltip) {
107+
options.title = entry.tooltip;
108+
}
105109
template.iconLabel.setLabel(entry.label, entry.detail, options);
106110

107111
if (this._target === OutlineTarget.OutlinePane) {
@@ -118,11 +122,12 @@ class CustomEditorOutlineRenderer implements ITreeRenderer<CustomEditorOutlineEn
118122
}));
119123

120124
const menu = template.elementDisposables.add(this._menuService.createMenu(MenuId.CustomEditorOutlineActionMenu, scopedContextKeyService));
121-
const actions = getActionBarActions(menu.getActions({ shouldForwardArgs: true }), g => /^inline/.test(g));
125+
const menuArg = { id: entry.id };
126+
const actions = getActionBarActions(menu.getActions({ shouldForwardArgs: true, arg: menuArg }), g => /^inline/.test(g));
122127
toolbar.setActions(actions.primary, actions.secondary);
123128

124129
template.elementDisposables.add(menu.onDidChange(() => {
125-
const actions = getActionBarActions(menu.getActions({ shouldForwardArgs: true }), g => /^inline/.test(g));
130+
const actions = getActionBarActions(menu.getActions({ shouldForwardArgs: true, arg: menuArg }), g => /^inline/.test(g));
126131
toolbar.setActions(actions.primary, actions.secondary);
127132
}));
128133
}
@@ -190,6 +195,7 @@ class CustomEditorExtensionOutline implements IOutline<CustomEditorOutlineEntry>
190195
private _entries: CustomEditorOutlineEntry[] = [];
191196
private _activeEntry: CustomEditorOutlineEntry | undefined;
192197
private _flatMap = new Map<string, CustomEditorOutlineEntry>();
198+
private _loadCts: CancellationTokenSource | undefined;
193199
private readonly _resource: URI;
194200
private readonly _viewType: string;
195201

@@ -300,7 +306,10 @@ class CustomEditorExtensionOutline implements IOutline<CustomEditorOutlineEntry>
300306
}
301307

302308
private async _loadItems(): Promise<void> {
303-
const cts = new CancellationTokenSource();
309+
// Cancel any previous in-flight request to avoid stale responses overwriting newer data
310+
this._loadCts?.cancel();
311+
this._loadCts?.dispose();
312+
const cts = this._loadCts = new CancellationTokenSource();
304313
try {
305314
const dtos = await this._providerService.provideOutline(this._viewType, cts.token);
306315
if (cts.token.isCancellationRequested) {
@@ -315,6 +324,9 @@ class CustomEditorExtensionOutline implements IOutline<CustomEditorOutlineEntry>
315324

316325
this._onDidChange.fire({});
317326
} finally {
327+
if (this._loadCts === cts) {
328+
this._loadCts = undefined;
329+
}
318330
cts.dispose();
319331
}
320332
}
@@ -351,6 +363,8 @@ class CustomEditorExtensionOutline implements IOutline<CustomEditorOutlineEntry>
351363
}
352364

353365
dispose(): void {
366+
this._loadCts?.cancel();
367+
this._loadCts?.dispose();
354368
this._disposables.dispose();
355369
this._onDidChange.dispose();
356370
}

src/vs/workbench/contrib/outline/browser/outlinePane.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ export class OutlinePane extends ViewPane implements IOutlinePane {
293293
menuActionOptions: { shouldForwardArgs: true },
294294
contextKeyService,
295295
getAnchor: () => e.anchor,
296+
getActionsContext: () => e.element,
296297
});
297298
}));
298299
}

0 commit comments

Comments
 (0)