diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 24f9c35129a..3cbd3e23033 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -132,7 +132,7 @@ export class CommandCenter { return await commands.executeCommand('vscode.open', right); } - return await commands.executeCommand('vscode.diff', left, right, title); + return await commands.executeCommand('vscode.diff', left, right, title, { preview: true }); } private getLeftResource(resource: Resource): Uri | undefined { diff --git a/src/vs/base/browser/ui/list/listWidget.ts b/src/vs/base/browser/ui/list/listWidget.ts index 5643cc768a9..d8f833da540 100644 --- a/src/vs/base/browser/ui/list/listWidget.ts +++ b/src/vs/base/browser/ui/list/listWidget.ts @@ -321,6 +321,7 @@ class MouseController implements IDisposable { this.disposables = []; this.disposables.push(view.addListener('mousedown', e => this.onMouseDown(e))); this.disposables.push(view.addListener('click', e => this.onPointer(e))); + this.disposables.push(view.addListener('dblclick', e => this.onDoubleClick(e))); this.disposables.push(view.addListener(TouchEventType.Tap, e => this.onPointer(e))); } @@ -362,6 +363,19 @@ class MouseController implements IDisposable { this.list.open(focus); } + private onDoubleClick(e: IListMouseEvent): void { + e.preventDefault(); + e.stopPropagation(); + + if (isSelectionChangeEvent(e)) { + return; + } + + const focus = this.list.getFocus(); + this.list.setSelection(focus); + this.list.pin(focus); + } + private changeSelection(e: IListMouseEvent, reference: number | undefined): void { const focus = e.index; @@ -574,6 +588,11 @@ export class List implements ISpliceable, IDisposable { return mapEvent(this._onOpen.event, indexes => this.toListEvent({ indexes })); } + private _onPin = new Emitter(); + @memoize get onPin(): Event> { + return mapEvent(this._onPin.event, indexes => this.toListEvent({ indexes })); + } + private _onDOMFocus = new Emitter(); get onDOMFocus(): Event { return this._onDOMFocus.event; } @@ -813,6 +832,10 @@ export class List implements ISpliceable, IDisposable { this._onOpen.fire(indexes); } + pin(indexes: number[]): void { + this._onPin.fire(indexes); + } + style(styles: IListStyles): void { const content: string[] = []; diff --git a/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts b/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts index f395ebd5eed..1d4064b4fb3 100644 --- a/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts +++ b/src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts @@ -25,6 +25,8 @@ import { VIEWLET_ID } from 'vs/workbench/parts/scm/common/scm'; import { FileLabel } from 'vs/workbench/browser/labels'; import { CountBadge } from 'vs/base/browser/ui/countBadge/countBadge'; import { ISCMService, ISCMProvider, ISCMResourceGroup, ISCMResource } from 'vs/workbench/services/scm/common/scm'; +import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; +import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IContextViewService, IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; @@ -243,7 +245,9 @@ export class SCMViewlet extends Viewlet { @IThemeService protected themeService: IThemeService, @IMenuService private menuService: IMenuService, @IModelService private modelService: IModelService, - @ICommandService private commandService: ICommandService + @ICommandService private commandService: ICommandService, + @IEditorGroupService private groupService: IEditorGroupService, + @IWorkbenchEditorService private editorService: IWorkbenchEditorService ) { super(VIEWLET_ID, telemetryService, themeService); @@ -320,6 +324,11 @@ export class SCMViewlet extends Viewlet { .filter(e => !!e && isSCMResource(e)) .on(this.open, this, this.disposables); + chain(this.list.onPin) + .map(e => e.elements[0]) + .filter(e => !!e && isSCMResource(e)) + .on(this.pin, this, this.disposables); + this.list.onContextMenu(this.onListContextMenu, this, this.disposables); this.disposables.push(this.list); @@ -406,6 +415,12 @@ export class SCMViewlet extends Viewlet { .done(undefined, onUnexpectedError); } + private pin(): void { + const activeEditor = this.editorService.getActiveEditor(); + const activeEditorInput = this.editorService.getActiveEditorInput(); + this.groupService.pinEditor(activeEditor.position, activeEditorInput); + } + getTitle(): string { const title = localize('source control', "Source Control"); const providerLabel = this.scmService.activeProvider && this.scmService.activeProvider.label;