From f9a9e1630c2f9f4403c861f9d35b7771d42d1623 Mon Sep 17 00:00:00 2001 From: vince-fugnitto Date: Fri, 1 Nov 2019 13:19:36 -0400 Subject: [PATCH] Open 'diff-editors' with a single-click Fixes #6479 - updated the opening of `diff-editors` from the `scm` widget to be triggered based on the preference `workbench.list.openMode`. - updated the preference name `list.openMode` to `workbench.list.openMode`. Signed-off-by: vince-fugnitto --- CHANGELOG.md | 4 +- packages/core/src/browser/core-preferences.ts | 4 +- .../src/browser/navigator-widget.tsx | 2 +- packages/scm/src/browser/scm-widget.tsx | 38 ++++++++++++++++--- 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5c1275964b28..d8863258f471d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,10 @@ ## v0.13.0 -Breaking changes: +- [scm] added handling when opening diff-editors to respect preference `workbench.list.openMode` [#6481](https://github.com/eclipse-theia/theia/pull/6481) +Breaking changes: +- [core] renamed preference `list.openMode` to `workbench.list.openMode` [#6481](https://github.com/eclipse-theia/theia/pull/6481) - [task] changed `TaskSchemaUpdater.update()` from asynchronous to synchronous [#6483](https://github.com/eclipse-theia/theia/pull/6483) - [monaco] monaco prefix has been removed from commands [#5590](https://github.com/eclipse-theia/theia/pull/5590) diff --git a/packages/core/src/browser/core-preferences.ts b/packages/core/src/browser/core-preferences.ts index 5ab6f0b055390..2721a58d77c9b 100644 --- a/packages/core/src/browser/core-preferences.ts +++ b/packages/core/src/browser/core-preferences.ts @@ -20,7 +20,7 @@ import { createPreferenceProxy, PreferenceProxy, PreferenceService, PreferenceCo export const corePreferenceSchema: PreferenceSchema = { 'type': 'object', properties: { - 'list.openMode': { + 'workbench.list.openMode': { type: 'string', enum: [ 'singleClick', @@ -50,7 +50,7 @@ export const corePreferenceSchema: PreferenceSchema = { export interface CoreConfiguration { 'application.confirmExit': 'never' | 'ifRequired' | 'always'; - 'list.openMode': 'singleClick' | 'doubleClick'; + 'workbench.list.openMode': 'singleClick' | 'doubleClick'; 'workbench.commandPalette.history': number; } diff --git a/packages/navigator/src/browser/navigator-widget.tsx b/packages/navigator/src/browser/navigator-widget.tsx index 7e7747fe77a74..686494017f0a6 100644 --- a/packages/navigator/src/browser/navigator-widget.tsx +++ b/packages/navigator/src/browser/navigator-widget.tsx @@ -249,7 +249,7 @@ export class FileNavigatorWidget extends FileTreeWidget { protected handleClickEvent(node: TreeNode | undefined, event: React.MouseEvent): void { const modifierKeyCombined: boolean = isOSX ? (event.shiftKey || event.metaKey) : (event.shiftKey || event.ctrlKey); - if (!modifierKeyCombined && node && this.corePreferences['list.openMode'] === 'singleClick') { + if (!modifierKeyCombined && node && this.corePreferences['workbench.list.openMode'] === 'singleClick') { this.model.previewNode(node); } super.handleClickEvent(node, event); diff --git a/packages/scm/src/browser/scm-widget.tsx b/packages/scm/src/browser/scm-widget.tsx index 3825b736fdb11..6bb8ebe7c0180 100644 --- a/packages/scm/src/browser/scm-widget.tsx +++ b/packages/scm/src/browser/scm-widget.tsx @@ -28,7 +28,7 @@ import { MenuModelRegistry, ActionMenuNode, CompositeMenuNode, MenuPath } from ' import { DisposableCollection, Disposable } from '@theia/core/lib/common/disposable'; import { ContextMenuRenderer, SELECTED_CLASS, StorageService, - ReactWidget, Key, LabelProvider, DiffUris, KeybindingRegistry, Widget, StatefulWidget + ReactWidget, Key, LabelProvider, DiffUris, KeybindingRegistry, Widget, StatefulWidget, CorePreferences } from '@theia/core/lib/browser'; import { AlertMessage } from '@theia/core/lib/browser/widgets/alert-message'; import { EditorManager, DiffNavigatorProvider, EditorWidget } from '@theia/editor/lib/browser'; @@ -51,6 +51,7 @@ export class ScmWidget extends ReactWidget implements StatefulWidget { static RESOURCE_INLINE_MENU = ['RESOURCE_INLINE_MENU']; static RESOURCE_CONTEXT_MENU = ['RESOURCE_CONTEXT_MENU']; + @inject(CorePreferences) protected readonly corePreferences: CorePreferences; @inject(ScmService) protected readonly scmService: ScmService; @inject(CommandRegistry) protected readonly commands: CommandRegistry; @inject(KeybindingRegistry) protected readonly keybindings: KeybindingRegistry; @@ -165,6 +166,7 @@ export class ScmWidget extends ReactWidget implements StatefulWidget { labelProvider={this.labelProvider} addScmListKeyListeners={this.addScmListKeyListeners} contextMenuRenderer={this.contextMenuRenderer} + corePreferences={this.corePreferences} /> {amendSupport && onMouseEnter={this.showHover} onMouseLeave={this.hideHover} ref={this.detectHover} - onClick={this.selectChange} - onDoubleClick={this.open}> + onClick={this.handleClick} + onDoubleClick={this.handleDoubleClick} >
{name} @@ -485,6 +488,30 @@ export class ScmResourceComponent extends ScmElement return [this.props.resource]; // TODO support multiselection } + /** + * Handle the single clicking of nodes present in the widget. + */ + protected handleClick = () => { + // Determine the behavior based on the preference value. + const isSingle = this.props.corePreferences && this.props.corePreferences['workbench.list.openMode'] === 'singleClick'; + if (isSingle) { + this.open(); + } else { + this.selectChange(); + } + } + + /** + * Handle the double clicking of nodes present in the widget. + */ + protected handleDoubleClick = () => { + // Determine the behavior based on the preference value. + const isDouble = this.props.corePreferences && this.props.corePreferences['workbench.list.openMode'] === 'doubleClick'; + // Nodes should only be opened through double clicking if the correct preference is set. + if (isDouble) { + this.open(); + } + } } export namespace ScmResourceComponent { export interface Props extends ScmElement.Props { @@ -522,7 +549,8 @@ export class ScmResourceGroupsContainer extends React.Component; + labelProvider={this.props.labelProvider} + corePreferences={this.props.corePreferences} />; } componentDidMount(): void {