From c4b4d3995ba81a80e36cd62d290dce2b23c8fd82 Mon Sep 17 00:00:00 2001 From: Jan Keromnes Date: Tue, 26 Nov 2019 15:45:42 +0100 Subject: [PATCH] [keybinding] Align 'Close Editor' keybinding with VS Code across OSes Signed-off-by: Jan Keromnes --- CHANGELOG.md | 1 + .../core/src/browser/common-frontend-contribution.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ec0f34bb3534..e278fd841bc86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - [core] updated handling when access is denied to the clipboard [#6516](https://github.com/eclipse-theia/theia/pull/6516) - [core] updated scrolling of widgets when re-setting their focus [#6621](https://github.com/eclipse-theia/theia/pull/6621) - [core] upgraded `reconnecting-websocket` to latest version [#6512](https://github.com/eclipse-theia/theia/pull/6512) +- [core] aligned `New File`, `Close Editor` and `Close Window` keybindings with VS Code across OSes [#6635](https://github.com/eclipse-theia/theia/pull/6635) - [cpp] moved the `cpp` extension to the [`theia-cpp-extensions`](https://github.com/eclipse-theia/theia-cpp-extensions) repo [#6505](https://github.com/eclipse-theia/theia/pull/6505) - [debug] added ability to re-use the terminal based on label and caption [#6619](https://github.com/eclipse-theia/theia/pull/6619) - [debug] added reloading of child variable nodes on `setValue` call [#6555](https://github.com/eclipse-theia/theia/pull/6555) diff --git a/packages/core/src/browser/common-frontend-contribution.ts b/packages/core/src/browser/common-frontend-contribution.ts index 3b492ca259e3c..ea2a975fc0268 100644 --- a/packages/core/src/browser/common-frontend-contribution.ts +++ b/packages/core/src/browser/common-frontend-contribution.ts @@ -30,13 +30,14 @@ import { AboutDialog } from './about-dialog'; import * as browser from './browser'; import URI from '../common/uri'; import { ContextKeyService } from './context-key-service'; -import { OS, isOSX } from '../common/os'; +import { OS, isOSX, isWindows } from '../common/os'; import { ResourceContextKey } from './resource-context-key'; import { UriSelection } from '../common/selection'; import { StorageService } from './storage-service'; import { Navigatable } from './navigatable'; import { QuickViewService } from './quick-view-service'; import { PrefixQuickOpenService } from './quick-open'; +import { environment } from '@theia/application-package/lib/environment'; export namespace CommonMenus { @@ -543,6 +544,10 @@ export class CommonFrontendContribution implements FrontendApplicationContributi return tabBar.currentTitle || undefined; } + private isElectron(): boolean { + return environment.electron.is(); + } + registerKeybindings(registry: KeybindingRegistry): void { if (supportCut) { registry.registerKeybinding({ @@ -599,7 +604,7 @@ export class CommonFrontendContribution implements FrontendApplicationContributi }, { command: CommonCommands.CLOSE_TAB.id, - keybinding: 'alt+w' + keybinding: (!this.isElectron() ? 'alt+w' : (isWindows ? 'ctrl+f4' : 'ctrlcmd+w')) }, { command: CommonCommands.CLOSE_OTHER_TABS.id,