mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-01 05:02:35 +01:00
scm: multiroot refresh
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { Uri, commands, scm, Disposable, window, workspace, QuickPickItem, OutputChannel, Range, WorkspaceEdit, Position, LineChange, SourceControlResourceGroup, SourceControlResourceState, TextDocumentShowOptions, ViewColumn } from 'vscode';
|
||||
import { Uri, commands, scm, Disposable, window, workspace, QuickPickItem, OutputChannel, Range, WorkspaceEdit, Position, LineChange, SourceControl, SourceControlResourceGroup, SourceControlResourceState, TextDocumentShowOptions, ViewColumn } from 'vscode';
|
||||
import { Ref, RefType, Git, GitErrorCodes, Branch } from './git';
|
||||
import { Repository, Resource, Status, CommitOptions, ResourceGroupType } from './repository';
|
||||
import { Model } from './model';
|
||||
@@ -145,8 +145,22 @@ export class CommandCenter {
|
||||
});
|
||||
}
|
||||
|
||||
@command('git.refresh', { repository: true })
|
||||
async refresh(repository: Repository): Promise<void> {
|
||||
@command('git.refresh')
|
||||
async refresh(sourceControl?: SourceControl): Promise<void> {
|
||||
let repository: Repository | undefined = undefined;
|
||||
|
||||
if (sourceControl) {
|
||||
repository = this.model.getRepositoryFromSourceControl(sourceControl);
|
||||
}
|
||||
|
||||
if (!repository) {
|
||||
repository = await this.model.pickRepository();
|
||||
}
|
||||
|
||||
if (!repository) {
|
||||
return;
|
||||
}
|
||||
|
||||
await repository.status();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { Uri, window, QuickPickItem, Disposable, SourceControlResourceGroup } from 'vscode';
|
||||
import { Uri, window, QuickPickItem, Disposable, SourceControl, SourceControlResourceGroup } from 'vscode';
|
||||
import { Repository, State } from './repository';
|
||||
import { memoize } from './decorators';
|
||||
import { toDisposable, filterEvent, once } from './util';
|
||||
@@ -60,7 +60,17 @@ export class Model {
|
||||
return pick && pick.repository;
|
||||
}
|
||||
|
||||
getRepositoryFromResourceGroup(resourceGroup?: SourceControlResourceGroup): Repository | undefined {
|
||||
getRepositoryFromSourceControl(sourceControl: SourceControl): Repository | undefined {
|
||||
for (let [, repository] of this.repositories) {
|
||||
if (sourceControl === repository.sourceControl) {
|
||||
return repository;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
getRepositoryFromResourceGroup(resourceGroup: SourceControlResourceGroup): Repository | undefined {
|
||||
for (let [, repository] of this.repositories) {
|
||||
if (resourceGroup === repository.mergeGroup || resourceGroup === repository.indexGroup || resourceGroup === repository.workingTreeGroup) {
|
||||
return repository;
|
||||
|
||||
@@ -199,6 +199,13 @@ class MainThreadSCMProvider implements ISCMProvider {
|
||||
return this.proxy.$provideOriginalResource(this.handle, uri);
|
||||
}
|
||||
|
||||
toJSON(): any {
|
||||
return {
|
||||
$mid: 5,
|
||||
handle: this.handle
|
||||
};
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
|
||||
}
|
||||
|
||||
@@ -307,6 +307,14 @@ export class ExtHostSCM {
|
||||
}
|
||||
|
||||
return sourceControl.getResourceGroup(arg.groupHandle);
|
||||
} else if (arg && arg.$mid === 5) {
|
||||
const sourceControl = this._sourceControls.get(arg.handle);
|
||||
|
||||
if (!sourceControl) {
|
||||
return arg;
|
||||
}
|
||||
|
||||
return sourceControl;
|
||||
}
|
||||
|
||||
return arg;
|
||||
|
||||
@@ -46,7 +46,8 @@ export class SCMMenus implements IDisposable {
|
||||
private updateTitleActions(): void {
|
||||
this.titleActions = [];
|
||||
this.titleSecondaryActions = [];
|
||||
fillInActions(this.titleMenu, null, { primary: this.titleActions, secondary: this.titleSecondaryActions });
|
||||
// TODO@joao: second arg used to be null
|
||||
fillInActions(this.titleMenu, { shouldForwardArgs: true }, { primary: this.titleActions, secondary: this.titleSecondaryActions });
|
||||
this._onDidChangeTitle.fire();
|
||||
}
|
||||
|
||||
|
||||
@@ -253,6 +253,7 @@ class SourceControlView extends CollapsibleView {
|
||||
@IContextMenuService protected contextMenuService: IContextMenuService,
|
||||
@IListService protected listService: IListService,
|
||||
@ICommandService protected commandService: ICommandService,
|
||||
@IMessageService protected messageService: IMessageService,
|
||||
@IWorkbenchEditorService protected editorService: IWorkbenchEditorService,
|
||||
@IEditorGroupService protected editorGroupService: IEditorGroupService,
|
||||
@IInstantiationService protected instantiationService: IInstantiationService
|
||||
@@ -318,6 +319,18 @@ class SourceControlView extends CollapsibleView {
|
||||
return this.menus.getTitleSecondaryActions();
|
||||
}
|
||||
|
||||
getActionItem(action: IAction): IActionItem {
|
||||
if (!(action instanceof MenuItemAction)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return new SCMMenuItemActionItem(action, this.keybindingService, this.messageService);
|
||||
}
|
||||
|
||||
getActionsContext(): any {
|
||||
return this.provider;
|
||||
}
|
||||
|
||||
private updateList(): void {
|
||||
const elements = this.provider.resources
|
||||
.reduce<(ISCMResourceGroup | ISCMResource)[]>((r, g) => [...r, g, ...g.resources.sort(resourceSorter)], []);
|
||||
|
||||
@@ -72,6 +72,8 @@ export interface IView extends IBaseView, IThemable {
|
||||
|
||||
getActionItem(action: IAction): IActionItem;
|
||||
|
||||
getActionsContext(): any;
|
||||
|
||||
showHeader(): boolean;
|
||||
|
||||
hideHeader(): boolean;
|
||||
@@ -171,6 +173,7 @@ export abstract class CollapsibleView extends AbstractCollapsibleView implements
|
||||
|
||||
protected updateActions(): void {
|
||||
this.toolBar.setActions(prepareActions(this.getActions()), prepareActions(this.getSecondaryActions()))();
|
||||
this.toolBar.context = this.getActionsContext();
|
||||
}
|
||||
|
||||
protected renderViewTree(container: HTMLElement): HTMLElement {
|
||||
@@ -228,6 +231,10 @@ export abstract class CollapsibleView extends AbstractCollapsibleView implements
|
||||
return null;
|
||||
}
|
||||
|
||||
public getActionsContext(): any {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public shutdown(): void {
|
||||
// Subclass to implement
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user