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, diff --git a/packages/core/src/electron-browser/menu/electron-menu-contribution.ts b/packages/core/src/electron-browser/menu/electron-menu-contribution.ts index 7c203504b11f5..91ce52b1f1b63 100644 --- a/packages/core/src/electron-browser/menu/electron-menu-contribution.ts +++ b/packages/core/src/electron-browser/menu/electron-menu-contribution.ts @@ -18,7 +18,7 @@ import * as electron from 'electron'; import { inject, injectable } from 'inversify'; import { Command, CommandContribution, CommandRegistry, - isOSX, MenuModelRegistry, MenuContribution, Disposable + isOSX, isWindows, MenuModelRegistry, MenuContribution, Disposable } from '../../common'; import { KeybindingContribution, KeybindingRegistry } from '../../browser'; import { FrontendApplication, FrontendApplicationContribution, CommonMenus } from '../../browser'; @@ -196,7 +196,7 @@ export class ElectronMenuContribution implements FrontendApplicationContribution }, { command: ElectronCommands.CLOSE_WINDOW.id, - keybinding: 'ctrlcmd+shift+w' + keybinding: (isOSX ? 'cmd+shift+w' : (isWindows ? 'ctrl+w' : /* Linux */ 'ctrl+q')) } ); } diff --git a/packages/workspace/src/browser/workspace-frontend-contribution.ts b/packages/workspace/src/browser/workspace-frontend-contribution.ts index 487144503b0cc..d2bdf91a1d1b7 100644 --- a/packages/workspace/src/browser/workspace-frontend-contribution.ts +++ b/packages/workspace/src/browser/workspace-frontend-contribution.ts @@ -141,6 +141,10 @@ export class WorkspaceFrontendContribution implements CommandContribution, Keybi } registerKeybindings(keybindings: KeybindingRegistry): void { + keybindings.registerKeybinding({ + command: WorkspaceCommands.NEW_FILE.id, + keybinding: this.isElectron() ? 'ctrlcmd+n' : 'alt+n', + }); keybindings.registerKeybinding({ command: isOSX || !this.isElectron() ? WorkspaceCommands.OPEN.id : WorkspaceCommands.OPEN_FILE.id, keybinding: 'ctrlcmd+alt+o',