mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 11:38:51 +01:00
@@ -113,13 +113,13 @@ export class CommandCenter {
|
||||
const right = this.getRightResource(resource);
|
||||
const title = this.getTitle(resource);
|
||||
|
||||
if (!left) {
|
||||
if (!right) {
|
||||
// TODO
|
||||
console.error('oh no');
|
||||
return;
|
||||
}
|
||||
if (!right) {
|
||||
// TODO
|
||||
console.error('oh no');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!left) {
|
||||
return await commands.executeCommand<void>('vscode.open', right);
|
||||
}
|
||||
|
||||
@@ -130,11 +130,11 @@ export class CommandCenter {
|
||||
switch (resource.type) {
|
||||
case Status.INDEX_MODIFIED:
|
||||
case Status.INDEX_RENAMED:
|
||||
return resource.uri.with({ scheme: 'git', query: 'HEAD' });
|
||||
return resource.original.with({ scheme: 'git', query: 'HEAD' });
|
||||
|
||||
case Status.MODIFIED:
|
||||
const uriString = resource.uri.toString();
|
||||
const [indexStatus] = this.model.indexGroup.resources.filter(r => r.uri.toString() === uriString);
|
||||
const uriString = resource.original.toString();
|
||||
const [indexStatus] = this.model.indexGroup.resources.filter(r => r.original.toString() === uriString);
|
||||
|
||||
if (indexStatus) {
|
||||
return resource.uri.with({ scheme: 'git' });
|
||||
@@ -149,6 +149,8 @@ export class CommandCenter {
|
||||
case Status.INDEX_MODIFIED:
|
||||
case Status.INDEX_ADDED:
|
||||
case Status.INDEX_COPIED:
|
||||
return resource.uri.with({ scheme: 'git' });
|
||||
|
||||
case Status.INDEX_RENAMED:
|
||||
return resource.uri.with({ scheme: 'git' });
|
||||
|
||||
@@ -159,6 +161,15 @@ export class CommandCenter {
|
||||
case Status.MODIFIED:
|
||||
case Status.UNTRACKED:
|
||||
case Status.IGNORED:
|
||||
const uriString = resource.uri.toString();
|
||||
const [indexStatus] = this.model.indexGroup.resources.filter(r => r.uri.toString() === uriString);
|
||||
|
||||
if (indexStatus && indexStatus.rename) {
|
||||
return indexStatus.rename;
|
||||
}
|
||||
|
||||
return resource.uri;
|
||||
|
||||
case Status.BOTH_MODIFIED:
|
||||
return resource.uri;
|
||||
}
|
||||
|
||||
@@ -43,8 +43,17 @@ export enum Status {
|
||||
|
||||
export class Resource implements SCMResource {
|
||||
|
||||
get uri(): Uri { return this._uri; }
|
||||
get uri(): Uri {
|
||||
if (this.rename && (this._type === Status.MODIFIED || this._type === Status.DELETED || this._type === Status.INDEX_RENAMED)) {
|
||||
return this.rename;
|
||||
}
|
||||
|
||||
return this._uri;
|
||||
}
|
||||
|
||||
get type(): Status { return this._type; }
|
||||
get original(): Uri { return this._uri; }
|
||||
get rename(): Uri | undefined { return this._rename; }
|
||||
|
||||
private static Icons = {
|
||||
light: {
|
||||
@@ -110,8 +119,8 @@ export class Resource implements SCMResource {
|
||||
return { strikeThrough: this.strikeThrough, light, dark };
|
||||
}
|
||||
|
||||
constructor(private _uri: Uri, private _type: Status) {
|
||||
|
||||
constructor(private _uri: Uri, private _type: Status, private _rename?: Uri) {
|
||||
// console.log(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,6 +444,7 @@ export class Model {
|
||||
|
||||
status.forEach(raw => {
|
||||
const uri = Uri.file(path.join(this.repositoryRoot, raw.path));
|
||||
const renameUri = raw.rename ? Uri.file(path.join(this.repositoryRoot, raw.rename)) : undefined;
|
||||
|
||||
switch (raw.x + raw.y) {
|
||||
case '??': return workingTree.push(new Resource(uri, Status.UNTRACKED));
|
||||
@@ -454,13 +464,13 @@ export class Model {
|
||||
case 'M': index.push(new Resource(uri, Status.INDEX_MODIFIED)); isModifiedInIndex = true; break;
|
||||
case 'A': index.push(new Resource(uri, Status.INDEX_ADDED)); break;
|
||||
case 'D': index.push(new Resource(uri, Status.INDEX_DELETED)); break;
|
||||
case 'R': index.push(new Resource(uri, Status.INDEX_RENAMED/*, raw.rename*/)); break;
|
||||
case 'R': index.push(new Resource(uri, Status.INDEX_RENAMED, renameUri)); break;
|
||||
case 'C': index.push(new Resource(uri, Status.INDEX_COPIED)); break;
|
||||
}
|
||||
|
||||
switch (raw.y) {
|
||||
case 'M': workingTree.push(new Resource(uri, Status.MODIFIED/*, raw.rename*/)); break;
|
||||
case 'D': workingTree.push(new Resource(uri, Status.DELETED/*, raw.rename*/)); break;
|
||||
case 'M': workingTree.push(new Resource(uri, Status.MODIFIED, renameUri)); break;
|
||||
case 'D': workingTree.push(new Resource(uri, Status.DELETED, renameUri)); break;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user