提交 0e0bc4d2 编写于 作者: J Joao Moreno

Merge branch 'eamodio-feature-git'

......@@ -156,7 +156,7 @@ export class CommandCenter {
await this._openResource(resource);
}
private async _openResource(resource: Resource): Promise<void> {
private async _openResource(resource: Resource, preview?: boolean): Promise<void> {
const left = this.getLeftResource(resource);
const right = this.getRightResource(resource);
const title = this.getTitle(resource);
......@@ -167,14 +167,10 @@ export class CommandCenter {
return;
}
const viewColumn = window.activeTextEditor && window.activeTextEditor.viewColumn || ViewColumn.One;
if (!left) {
return await commands.executeCommand<void>('vscode.open', right, viewColumn);
}
const opts: TextDocumentShowOptions = {
viewColumn
preserveFocus: true,
preview: preview,
viewColumn: window.activeTextEditor && window.activeTextEditor.viewColumn || ViewColumn.One
};
const activeTextEditor = window.activeTextEditor;
......@@ -183,6 +179,12 @@ export class CommandCenter {
opts.selection = activeTextEditor.selection;
}
if (!left) {
const document = await workspace.openTextDocument(right);
await window.showTextDocument(document, opts);
return;
}
return await commands.executeCommand<void>('vscode.diff', left, right, title, opts);
}
......@@ -297,14 +299,14 @@ export class CommandCenter {
}
@command('git.openFile')
async openFile(arg?: Resource | Uri): Promise<void> {
let uri: Uri | undefined;
async openFile(arg?: Resource | Uri, ...resourceStates: SourceControlResourceState[]): Promise<void> {
let uris: Uri[] | undefined;
if (arg instanceof Uri) {
if (arg.scheme === 'git') {
uri = Uri.file(fromGitUri(arg).path);
uris = [Uri.file(fromGitUri(arg).path)];
} else if (arg.scheme === 'file') {
uri = arg;
uris = [arg];
}
} else {
let resource = arg;
......@@ -315,23 +317,34 @@ export class CommandCenter {
}
if (resource) {
uri = resource.resourceUri;
uris = [...resourceStates.map(r => r.resourceUri), resource.resourceUri];
}
}
if (!uri) {
if (!uris) {
return;
}
const activeTextEditor = window.activeTextEditor && window.activeTextEditor;
const isSameUri = activeTextEditor && activeTextEditor.document.uri.toString() === uri.toString();
const selections = activeTextEditor && activeTextEditor.selections;
const viewColumn = activeTextEditor && activeTextEditor.viewColumn || ViewColumn.One;
await commands.executeCommand<void>('vscode.open', uri, viewColumn);
if (isSameUri && selections && window.activeTextEditor) {
window.activeTextEditor.selections = selections;
const preview = uris.length === 1 ? true : false;
const activeTextEditor = window.activeTextEditor;
for (const uri of uris) {
// If the active editor matches the current uri, get its selection
const selections = activeTextEditor && activeTextEditor.document.uri.toString() === uri.toString()
? activeTextEditor.selections
: undefined;
const opts: TextDocumentShowOptions = {
preserveFocus: true,
preview: preview,
viewColumn: activeTextEditor && activeTextEditor.viewColumn || ViewColumn.One
};
const document = await workspace.openTextDocument(uri);
await window.showTextDocument(document, opts);
if (selections && window.activeTextEditor) {
window.activeTextEditor.selections = selections;
}
}
}
......@@ -362,22 +375,37 @@ export class CommandCenter {
}
@command('git.openChange')
async openChange(arg?: Resource | Uri): Promise<void> {
let resource: Resource | undefined = undefined;
async openChange(arg?: Resource | Uri, ...resourceStates: SourceControlResourceState[]): Promise<void> {
let resources: Resource[] | undefined = undefined;
if (arg instanceof Resource) {
resource = arg;
} else if (arg instanceof Uri) {
resource = this.getSCMResource(arg);
} else {
resource = this.getSCMResource();
if (arg instanceof Uri) {
const resource = this.getSCMResource(arg);
if (resource !== undefined) {
resources = [resource];
}
}
else {
let resource: Resource | undefined = undefined;
if (!resource) {
if (arg instanceof Resource) {
resource = arg;
} else {
resource = this.getSCMResource();
}
if (resource) {
resources = [...resourceStates as Resource[], resource];
}
}
if (!resources) {
return;
}
return await this._openResource(resource);
const preview = resources.length === 1 ? undefined : false;
for (const resource of resources) {
await this._openResource(resource, preview);
}
}
@command('git.stage')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册