Skip to content

Commit 93c7ecf

Browse files
author
Benjamin Pasero
committed
Scroll to switch tabs: Reverse mode is strange when tabs overflow (fix microsoft#96405)
1 parent ca0af15 commit 93c7ecf

3 files changed

Lines changed: 10 additions & 21 deletions

File tree

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -329,23 +329,18 @@ export class TabsTitleControl extends TitleControl {
329329
}
330330

331331
// Shift-key enables or disables this behaviour depending on the setting
332-
if (this.accessor.partOptions.scrollToSwitchTabs === 'off') {
333-
if (!e.shiftKey) {
334-
return; // 'off': only enable this when Shift-key is pressed
335-
}
336-
} else {
332+
if (this.accessor.partOptions.scrollToSwitchTabs === true) {
337333
if (e.shiftKey) {
338334
return; // 'on': only enable this when Shift-key is not pressed
339335
}
336+
} else {
337+
if (!e.shiftKey) {
338+
return; // 'off': only enable this when Shift-key is pressed
339+
}
340340
}
341341

342342
// Figure out scrolling direction
343-
let scrollingUp = e.deltaX < 0 || e.deltaY < 0;
344-
if (this.accessor.partOptions.scrollToSwitchTabs === 'reverse') {
345-
scrollingUp = !scrollingUp;
346-
}
347-
348-
const nextEditor = this.group.getEditorByIndex(this.group.getIndexOfEditor(activeEditor) + (scrollingUp ? -1 : 1));
343+
const nextEditor = this.group.getEditorByIndex(this.group.getIndexOfEditor(activeEditor) + (e.deltaX < 0 || e.deltaY < 0 /* scrolling up */ ? -1 : 1));
349344
if (!nextEditor) {
350345
return;
351346
}

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,9 @@ import { workbenchConfigurationNodeBase } from 'vs/workbench/common/configuratio
3333
'default': true
3434
},
3535
'workbench.editor.scrollToSwitchTabs': {
36-
'type': 'string',
37-
'enum': ['off', 'natural', 'reverse'],
38-
'enumDescriptions': [
39-
nls.localize('workbench.editor.scrollToSwitchTabs.off', "Tabs will reveal when scrolling with the mouse but not open. You can press and hold the Shift-key to switch tabs while scrolling."),
40-
nls.localize('workbench.editor.scrollToSwitchTabs.natural', "Tabs will open when scrolling with the mouse in natural scrolling direction (scroll up to switch to the tab on the left and down for the tab on the right). You can press and hold the Shift-key to disable this behaviour for that duration."),
41-
nls.localize('workbench.editor.scrollToSwitchTabs.reverse', "Tabs will open when scrolling with the mouse in reverse scrolling direction (scroll down to switch to the tab on the left and up for the tab on the right). You can press and hold the Shift-key to disable this behaviour for that duration."),
42-
],
43-
'default': 'off',
44-
'description': nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'scrollToSwitchTabs' }, "Controls wether scrolling over tabs will open them or not. By default tabs will only reveal upon scrolling, but not open. You can press and hold the Shift-key while scrolling to change this behaviour for that duration.")
36+
'type': 'boolean',
37+
'description': nls.localize({ comment: ['This is the description for a setting. Values surrounded by single quotes are not to be translated.'], key: 'scrollToSwitchTabs' }, "Controls wether scrolling over tabs will open them or not. By default tabs will only reveal upon scrolling, but not open. You can press and hold the Shift-key while scrolling to change this behaviour for that duration."),
38+
'default': false
4539
},
4640
'workbench.editor.highlightModifiedTabs': {
4741
'type': 'boolean',

src/vs/workbench/common/editor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ export interface IWorkbenchEditorConfiguration {
13041304

13051305
interface IEditorPartConfiguration {
13061306
showTabs?: boolean;
1307-
scrollToSwitchTabs?: 'off' | 'natural' | 'reverse';
1307+
scrollToSwitchTabs?: boolean;
13081308
highlightModifiedTabs?: boolean;
13091309
tabCloseButton?: 'left' | 'right' | 'off';
13101310
tabSizing?: 'fit' | 'shrink';

0 commit comments

Comments
 (0)