Skip to content

Commit

Permalink
Open 'diff-editors' with a single-click
Browse files Browse the repository at this point in the history
Fixes eclipse-theia#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 <vincent.fugnitto@ericsson.com>
  • Loading branch information
vince-fugnitto authored and akosyakov committed Feb 24, 2020
1 parent 3e1f74a commit a85aef8
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 9 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/browser/core-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/navigator/src/browser/navigator-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export class FileNavigatorWidget extends FileTreeWidget {

protected handleClickEvent(node: TreeNode | undefined, event: React.MouseEvent<HTMLElement>): 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);
Expand Down
37 changes: 32 additions & 5 deletions packages/scm/src/browser/scm-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down Expand Up @@ -165,6 +166,7 @@ export class ScmWidget extends ReactWidget implements StatefulWidget {
labelProvider={this.labelProvider}
addScmListKeyListeners={this.addScmListKeyListeners}
contextMenuRenderer={this.contextMenuRenderer}
corePreferences={this.corePreferences}
/>
{amendSupport && <ScmAmendComponent
key={`amend:${repository.provider.rootUri}`}
Expand Down Expand Up @@ -378,7 +380,8 @@ export namespace ScmWidget {
menus: MenuModelRegistry;
contextKeys: ScmContextKeyService;
labelProvider: LabelProvider;
contextMenuRenderer: ContextMenuRenderer
contextMenuRenderer: ContextMenuRenderer;
corePreferences?: CorePreferences;
}

}
Expand Down Expand Up @@ -454,8 +457,8 @@ export class ScmResourceComponent extends ScmElement<ScmResourceComponent.Props>
onMouseEnter={this.showHover}
onMouseLeave={this.hideHover}
ref={this.detectHover}
onClick={this.selectChange}
onDoubleClick={this.open}>
onClick={this.handleClick}
onDoubleClick={this.handleDoubleClick} >
<div className='noWrapInfo' >
<span className={icon + ' file-icon'} />
<span className='name'>{name}</span>
Expand Down Expand Up @@ -485,6 +488,29 @@ export class ScmResourceComponent extends ScmElement<ScmResourceComponent.Props>
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';
this.selectChange();
if (isSingle) {
this.open();
}
}

/**
* 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 {
Expand Down Expand Up @@ -522,7 +548,8 @@ export class ScmResourceGroupsContainer extends React.Component<ScmResourceGroup
commands={this.props.commands}
menus={this.props.menus}
contextKeys={this.props.contextKeys}
labelProvider={this.props.labelProvider} />;
labelProvider={this.props.labelProvider}
corePreferences={this.props.corePreferences} />;
}

componentDidMount(): void {
Expand Down

0 comments on commit a85aef8

Please sign in to comment.