Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/vs/platform/windows/electron-main/windowImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1042,6 +1042,16 @@ export class CodeWindow extends BaseWindow implements ICodeWindow {

private onConfigurationUpdated(e?: IConfigurationChangeEvent): void {

// Swipe command support (macOS)
if (isMacintosh && (!e || e.affectsConfiguration('workbench.editor.swipeToNavigate'))) {
const swipeToNavigate = this.configurationService.getValue<boolean>('workbench.editor.swipeToNavigate');
if (swipeToNavigate) {
this.registerSwipeListener();
} else {
this.swipeListenerDisposable.clear();
}
}

// Menubar
if (!e || e.affectsConfiguration(MenuSettings.MenuBarVisibility)) {
const newMenuBarVisibility = this.getMenuBarVisibility();
Expand Down Expand Up @@ -1085,6 +1095,22 @@ export class CodeWindow extends BaseWindow implements ICodeWindow {
}
}

private readonly swipeListenerDisposable = this._register(new MutableDisposable());

private registerSwipeListener(): void {
this.swipeListenerDisposable.value = Event.fromNodeEventEmitter<string>(this._win, 'swipe', (event: Electron.Event, cmd: string) => cmd)(cmd => {
if (!this.isReady) {
return; // window must be ready
}

if (cmd === 'left') {
this.send('vscode:runAction', { id: 'workbench.action.openPreviousRecentlyUsedEditor', from: 'mouse' });
} else if (cmd === 'right') {
this.send('vscode:runAction', { id: 'workbench.action.openNextRecentlyUsedEditor', from: 'mouse' });
}
});
}

addTabbedWindow(window: ICodeWindow): void {
if (isMacintosh && window.win) {
this._win.addTabbedWindow(window.win);
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/browser/parts/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const DEFAULT_EDITOR_PART_OPTIONS: IEditorPartOptions = {
scrollToSwitchTabs: false,
enablePreviewFromCodeNavigation: false,
closeOnFileDelete: false,
swipeToNavigate: false,
mouseBackForwardToNavigate: true,
restoreViewState: true,
splitInGroupLayout: 'horizontal',
Expand Down Expand Up @@ -137,6 +138,7 @@ function validateEditorPartOptions(options: IEditorPartOptions): IEditorPartOpti
'closeOnFileDelete': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['closeOnFileDelete']),
'closeEmptyGroups': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['closeEmptyGroups']),
'revealIfOpen': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['revealIfOpen']),
'swipeToNavigate': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['swipeToNavigate']),
'mouseBackForwardToNavigate': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['mouseBackForwardToNavigate']),
'restoreViewState': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['restoreViewState']),
'splitOnDragAndDrop': new BooleanVerifier(DEFAULT_EDITOR_PART_OPTIONS['splitOnDragAndDrop']),
Expand Down
6 changes: 6 additions & 0 deletions src/vs/workbench/browser/workbench.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,12 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
'description': localize('revealIfOpen', "Controls whether an editor is revealed in any of the visible groups if opened. If disabled, an editor will prefer to open in the currently active editor group. If enabled, an already opened editor will be revealed instead of opened again in the currently active editor group. Note that there are some cases where this setting is ignored, such as when forcing an editor to open in a specific group or to the side of the currently active group."),
'default': false
},
'workbench.editor.swipeToNavigate': {
'type': 'boolean',
'description': localize('swipeToNavigate', "Navigate between open files using three-finger swipe horizontally. Note that System Preferences > Trackpad > More Gestures must be set to 'Swipe with two or three fingers'."),
'default': false,
'included': isMacintosh && !isWeb
},
'workbench.editor.mouseBackForwardToNavigate': {
'type': 'boolean',
'description': localize('mouseBackForwardToNavigate', "Enables the use of mouse buttons four and five for commands 'Go Back' and 'Go Forward'."),
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/common/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,7 @@ interface IEditorPartConfiguration {
closeEmptyGroups?: boolean;
autoLockGroups?: Set<string>;
revealIfOpen?: boolean;
swipeToNavigate?: boolean;
mouseBackForwardToNavigate?: boolean;
labelFormat?: 'default' | 'short' | 'medium' | 'long';
restoreViewState?: boolean;
Expand Down
Loading