Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[keybinding] Align more Electron/browser keybindings with VS Code #6635

Merged
merged 3 commits into from
Dec 1, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions packages/core/src/browser/common-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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'))
}
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down