Skip to content

Commit a3e0c91

Browse files
committed
1.Moved the settings into options.
2.Moved tab refresh to updateOptions. 3.Simplified the code using a ternary operator. 4.Renamed the setting from 'workbench.tabIndex.enabled' to 'workbench.editor.showTabIndex'. 5.Removed some irrelevant code.
1 parent 4265509 commit a3e0c91

File tree

5 files changed

+11
-20
lines changed

5 files changed

+11
-20
lines changed

src/vs/workbench/browser/parts/editor/editor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const DEFAULT_EDITOR_PART_OPTIONS: IEditorPartOptions = {
3333
tabActionLocation: 'right',
3434
tabActionCloseVisibility: true,
3535
tabActionUnpinVisibility: true,
36+
showTabIndex: false,
3637
alwaysShowEditorActions: false,
3738
tabSizing: 'fit',
3839
tabSizingFixedMinWidth: 50,
@@ -123,6 +124,7 @@ function validateEditorPartOptions(options: IEditorPartOptions): IEditorPartOpti
123124
'highlightModifiedTabs': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['highlightModifiedTabs']),
124125
'tabActionCloseVisibility': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['tabActionCloseVisibility']),
125126
'tabActionUnpinVisibility': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['tabActionUnpinVisibility']),
127+
'showTabIndex': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['showTabIndex']),
126128
'alwaysShowEditorActions': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['alwaysShowEditorActions']),
127129
'pinnedTabsOnSeparateRow': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['pinnedTabsOnSeparateRow']),
128130
'focusRecentEditorAfterClose': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['focusRecentEditorAfterClose']),

src/vs/workbench/browser/parts/editor/multiEditorTabsControl.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ import { IReadonlyEditorGroupModel } from 'vs/workbench/common/editor/editorGrou
5858
import { IHostService } from 'vs/workbench/services/host/browser/host';
5959
import { BugIndicatingError } from 'vs/base/common/errors';
6060
import { applyDragImage } from 'vs/base/browser/dnd';
61-
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
6261

6362
interface IEditorInputLabel {
6463
readonly editor: EditorInput;
@@ -152,7 +151,6 @@ export class MultiEditorTabsControl extends EditorTabsControl {
152151
@IPathService private readonly pathService: IPathService,
153152
@ITreeViewsDnDService private readonly treeViewsDragAndDropService: ITreeViewsDnDService,
154153
@IEditorResolverService editorResolverService: IEditorResolverService,
155-
@IConfigurationService private readonly configurationService: IConfigurationService,
156154
@IHostService hostService: IHostService,
157155
) {
158156
super(parent, editorPartsView, groupsView, groupView, tabsModel, contextMenuService, instantiationService, contextKeyService, keybindingService, notificationService, quickInputService, themeService, editorResolverService, hostService);
@@ -164,11 +162,6 @@ export class MultiEditorTabsControl extends EditorTabsControl {
164162

165163
// React to decorations changing for our resource labels
166164
this._register(this.tabResourceLabels.onDidChangeDecorations(() => this.doHandleDecorationsChange()));
167-
this._register(this.configurationService.onDidChangeConfiguration(e => {
168-
if (e.affectsConfiguration('workbench.tabIndex.enabled')) {
169-
this.doUpdateEditorLabels();
170-
}
171-
}));
172165
}
173166

174167
protected override create(parent: HTMLElement): void {
@@ -766,6 +759,7 @@ export class MultiEditorTabsControl extends EditorTabsControl {
766759
oldOptions.hasIcons !== newOptions.hasIcons ||
767760
oldOptions.highlightModifiedTabs !== newOptions.highlightModifiedTabs ||
768761
oldOptions.wrapTabs !== newOptions.wrapTabs ||
762+
oldOptions.showTabIndex !== newOptions.showTabIndex ||
769763
!equals(oldOptions.decorations, newOptions.decorations)
770764
) {
771765
this.redraw();
@@ -1608,13 +1602,7 @@ export class MultiEditorTabsControl extends EditorTabsControl {
16081602
fileDecorationBadges = false; // not enough space when sticky tabs are compact
16091603
} else {
16101604

1611-
const enabled = this.configurationService.getValue<boolean>('workbench.tabIndex.enabled');
1612-
1613-
if (enabled) {
1614-
name = (tabIndex + 1).toString() + '. ' + tabLabel.name;
1615-
} else {
1616-
name = tabLabel.name;
1617-
}
1605+
name = options.showTabIndex ? `${tabIndex + 1}. ${tabLabel.name}` : tabLabel.name
16181606
description = tabLabel.description || '';
16191607
}
16201608

src/vs/workbench/browser/workbench.contribution.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
198198
default: true,
199199
description: localize('workbench.editor.tabActionUnpinVisibility', "Controls the visibility of the tab unpin action button.")
200200
},
201+
'workbench.editor.showTabIndex': {
202+
'type': 'boolean',
203+
'default': false,
204+
'description': localize('workbench.editor.showTabIndex', "When enabled, will show the tab index.")
205+
},
201206
'workbench.editor.tabSizing': {
202207
'type': 'string',
203208
'enum': ['fit', 'shrink', 'fixed'],
@@ -624,11 +629,6 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
624629
'default': true,
625630
'description': localize('tips.enabled', "When enabled, will show the watermark tips when no editor is open.")
626631
},
627-
'workbench.tabIndex.enabled': {
628-
'type': 'boolean',
629-
'default': false,
630-
'description': localize('tabIndex.enabled', "When enabled, will show the tab index.")
631-
},
632632
}
633633
});
634634

src/vs/workbench/common/editor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,7 @@ interface IEditorPartConfiguration {
12161216
tabActionLocation?: 'left' | 'right';
12171217
tabActionCloseVisibility?: boolean;
12181218
tabActionUnpinVisibility?: boolean;
1219+
showTabIndex?: boolean;
12191220
alwaysShowEditorActions?: boolean;
12201221
tabSizing?: 'fit' | 'shrink' | 'fixed';
12211222
tabSizingFixedMinWidth?: number;

src/vs/workbench/contrib/preferences/browser/settingsLayout.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export const tocData: ITOCEntry<string> = {
101101
{
102102
id: 'workbench/appearance',
103103
label: localize('appearance', "Appearance"),
104-
settings: ['workbench.activityBar.*', 'workbench.*color*', 'workbench.fontAliasing', 'workbench.iconTheme', 'workbench.sidebar.location', 'workbench.*.visible', 'workbench.tips.enabled', 'workbench.tabIndex.enabled', 'workbench.tree.*', 'workbench.view.*']
104+
settings: ['workbench.activityBar.*', 'workbench.*color*', 'workbench.fontAliasing', 'workbench.iconTheme', 'workbench.sidebar.location', 'workbench.*.visible', 'workbench.tips.enabled', 'workbench.tree.*', 'workbench.view.*']
105105
},
106106
{
107107
id: 'workbench/breadcrumbs',

0 commit comments

Comments
 (0)