Skip to content

Commit

Permalink
fixes #93493
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Apr 9, 2020
1 parent 83af777 commit 8ceb90a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions extensions/git/src/commands.ts
Expand Up @@ -290,7 +290,7 @@ export class CommandCenter {
}

@command('git.openResource')
async openResource(resource: Resource): Promise<void> {
async openResource(resource: Resource, preserveFocus: boolean): Promise<void> {
const repository = this.model.getRepository(resource.resourceUri);

if (!repository) {
Expand All @@ -301,7 +301,7 @@ export class CommandCenter {
const openDiffOnClick = config.get<boolean>('openDiffOnClick');

if (openDiffOnClick) {
await this._openResource(resource, undefined, true, false);
await this._openResource(resource, undefined, preserveFocus, false);
} else {
await this.openFile(resource);
}
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/browser/mainThreadSCM.ts
Expand Up @@ -71,8 +71,8 @@ class MainThreadSCMResource implements ISCMResource {
public decorations: ISCMResourceDecorations
) { }

open(): Promise<void> {
return this.proxy.$executeResourceCommand(this.sourceControlHandle, this.groupHandle, this.handle);
open(preserveFocus: boolean): Promise<void> {
return this.proxy.$executeResourceCommand(this.sourceControlHandle, this.groupHandle, this.handle, preserveFocus);
}

toJSON(): any {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/common/extHost.protocol.ts
Expand Up @@ -1388,7 +1388,7 @@ export interface ExtHostTerminalServiceShape {
export interface ExtHostSCMShape {
$provideOriginalResource(sourceControlHandle: number, uri: UriComponents, token: CancellationToken): Promise<UriComponents | null>;
$onInputBoxValueChange(sourceControlHandle: number, value: string): void;
$executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number): Promise<void>;
$executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number, preserveFocus: boolean): Promise<void>;
$validateInput(sourceControlHandle: number, value: string, cursorPosition: number): Promise<[string, number] | undefined>;
$setSelectedSourceControls(selectedSourceControlHandles: number[]): Promise<void>;
}
Expand Down
8 changes: 4 additions & 4 deletions src/vs/workbench/api/common/extHostSCM.ts
Expand Up @@ -266,14 +266,14 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
return this._resourceStatesMap.get(handle);
}

$executeResourceCommand(handle: number): Promise<void> {
$executeResourceCommand(handle: number, preserveFocus: boolean): Promise<void> {
const command = this._resourceStatesCommandsMap.get(handle);

if (!command) {
return Promise.resolve(undefined);
}

return asPromise(() => this._commands.executeCommand(command.command, ...(command.arguments || [])));
return asPromise(() => this._commands.executeCommand(command.command, ...(command.arguments || []), preserveFocus));
}

_takeResourceStateSnapshot(): SCMRawResourceSplice[] {
Expand Down Expand Up @@ -628,7 +628,7 @@ export class ExtHostSCM implements ExtHostSCMShape {
return Promise.resolve(undefined);
}

$executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number): Promise<void> {
$executeResourceCommand(sourceControlHandle: number, groupHandle: number, handle: number, preserveFocus: boolean): Promise<void> {
this.logService.trace('ExtHostSCM#$executeResourceCommand', sourceControlHandle, groupHandle, handle);

const sourceControl = this._sourceControls.get(sourceControlHandle);
Expand All @@ -643,7 +643,7 @@ export class ExtHostSCM implements ExtHostSCMShape {
return Promise.resolve(undefined);
}

return group.$executeResourceCommand(handle);
return group.$executeResourceCommand(handle, preserveFocus);
}

$validateInput(sourceControlHandle: number, value: string, cursorPosition: number): Promise<[string, number] | undefined> {
Expand Down
16 changes: 9 additions & 7 deletions src/vs/workbench/contrib/scm/browser/repositoryPane.ts
Expand Up @@ -27,7 +27,7 @@ import { ActionBar, IActionViewItemProvider } from 'vs/base/browser/ui/actionbar
import { IThemeService, LIGHT, registerThemingParticipant, IFileIconTheme } from 'vs/platform/theme/common/themeService';
import { isSCMResource, isSCMResourceGroup, connectPrimaryMenuToInlineActionBar } from './util';
import { attachBadgeStyler } from 'vs/platform/theme/common/styler';
import { WorkbenchCompressibleObjectTree } from 'vs/platform/list/browser/listService';
import { WorkbenchCompressibleObjectTree, TreeResourceNavigator, IOpenEvent } from 'vs/platform/list/browser/listService';
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { disposableTimeout, ThrottledDelayer } from 'vs/base/common/async';
import { INotificationService } from 'vs/platform/notification/common/notification';
Expand Down Expand Up @@ -877,10 +877,8 @@ export class RepositoryPane extends ViewPane {
accessibilityProvider: new SCMAccessibilityProvider()
}) as WorkbenchCompressibleObjectTree<TreeElement, FuzzyScore>;

this._register(Event.chain(this.tree.onDidOpen)
.map(e => e.elements[0])
.filter<ISCMResource>((e): e is ISCMResource => !!e && !isSCMResourceGroup(e) && !ResourceTree.isResourceNode(e))
.on(this.open, this));
const navigator = this._register(new TreeResourceNavigator(this.tree, { openOnSelection: false }));
this._register(navigator.onDidOpenResource(this.open, this));

this._register(Event.chain(this.tree.onDidPin)
.map(e => e.elements[0])
Expand Down Expand Up @@ -1020,8 +1018,12 @@ export class RepositoryPane extends ViewPane {
return this.repository.provider;
}

private open(e: ISCMResource): void {
e.open();
private open(e: IOpenEvent<TreeElement | null>): void {
if (!e.element || isSCMResourceGroup(e.element) || ResourceTree.isResourceNode(e.element)) {
return;
}

e.element.open(!!e.editorOptions.preserveFocus);
}

private pin(): void {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/scm/common/scm.ts
Expand Up @@ -30,7 +30,7 @@ export interface ISCMResource {
readonly resourceGroup: ISCMResourceGroup;
readonly sourceUri: URI;
readonly decorations: ISCMResourceDecorations;
open(): Promise<void>;
open(preserveFocus: boolean): Promise<void>;
}

export interface ISCMResourceGroup extends ISequence<ISCMResource> {
Expand Down

0 comments on commit 8ceb90a

Please sign in to comment.