瀏覽代碼

Removes root node from file/line history

main
Eric Amodio 4 年之前
父節點
當前提交
772601a424
共有 4 個檔案被更改,包括 48 行新增13 行删除
  1. +20
    -3
      src/views/nodes/fileHistoryNode.ts
  2. +2
    -2
      src/views/nodes/fileHistoryTrackerNode.ts
  3. +24
    -6
      src/views/nodes/lineHistoryNode.ts
  4. +2
    -2
      src/views/nodes/lineHistoryTrackerNode.ts

+ 20
- 3
src/views/nodes/fileHistoryNode.ts 查看文件

@ -77,6 +77,14 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
}
}
this.view.titleContext = `${this.uri.fileName}${
this.uri.sha
? ` ${this.uri.sha === GitRevision.deletedOrMissing ? this.uri.shortSha : `(${this.uri.shortSha})`}`
: ''
}`;
void this.ensureSubscription();
if (children.length === 0) return [new MessageNode(this.view, this, 'No file history could be found.')];
return children;
}
@ -96,6 +104,12 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
this.uri.sha == null ? '' : `\n\n${this.uri.sha}`
}`;
this.view.titleContext = `${this.uri.fileName}${
this.uri.sha
? ` ${this.uri.sha === GitRevision.deletedOrMissing ? this.uri.shortSha : `(${this.uri.shortSha})`}`
: ''
}`;
void this.ensureSubscription();
return item;
@ -122,7 +136,7 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
Logger.log(`FileHistoryNode.onRepoChanged(${e.changes.join()}); triggering node refresh`);
void this.triggerChange();
void (this.parent ?? this).triggerChange(true);
}
private onRepoFileSystemChanged(e: RepositoryFileSystemChangeEvent) {
@ -132,7 +146,7 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
`FileHistoryNode${this.id}.onRepoFileSystemChanged(${this.uri.toString(true)}); triggering node refresh`,
);
void this.triggerChange();
void (this.parent ?? this).triggerChange(true);
}
@gate()
@ -169,6 +183,9 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
this._log = log;
this.limit = log?.count;
void this.triggerChange(false);
void (this.parent ?? this).triggerChange(false);
if (this.parent) {
this.view.triggerNodeChange(this.parent);
}
}
}

+ 2
- 2
src/views/nodes/fileHistoryTrackerNode.ts 查看文件

@ -35,7 +35,7 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
this._child = undefined;
}
getChildren(): ViewNode[] {
getChildren(): ViewNode[] | Promise<ViewNode[]> {
if (this._child == null) {
if (this._fileUri == null && this.uri === unknownGitUri) {
return [
@ -53,7 +53,7 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
this._child = new FileHistoryNode(fileUri, this.view, this);
}
return [this._child];
return this._child.getChildren();
}
getTreeItem(): TreeItem {

+ 24
- 6
src/views/nodes/lineHistoryNode.ts 查看文件

@ -198,14 +198,25 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
}
}
const lines = this.selection.isSingleLine
? `:${this.selection.start.line + 1}`
: `:${this.selection.start.line + 1}-${this.selection.end.line + 1}`;
this.view.titleContext = `${this.uri.fileName}${lines}${
this.uri.sha
? ` ${this.uri.sha === GitRevision.deletedOrMissing ? this.uri.shortSha : `(${this.uri.shortSha})`}`
: ''
}`;
void this.ensureSubscription();
if (children.length === 0) return [new MessageNode(this.view, this, 'No line history could be found.')];
return children;
}
getTreeItem(): TreeItem {
const lines = this.selection.isSingleLine
? ` #${this.selection.start.line + 1}`
: ` #${this.selection.start.line + 1}-${this.selection.end.line + 1}`;
? `:${this.selection.start.line + 1}`
: `:${this.selection.start.line + 1}-${this.selection.end.line + 1}`;
const item = new TreeItem(
`${this.uri.fileName}${lines}${
this.uri.sha
@ -222,7 +233,11 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
void this.ensureSubscription();
this.view.titleContext = lines;
this.view.titleContext = `${this.uri.fileName}${lines}${
this.uri.sha
? ` ${this.uri.sha === GitRevision.deletedOrMissing ? this.uri.shortSha : `(${this.uri.shortSha})`}`
: ''
}`;
return item;
}
@ -247,7 +262,7 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
Logger.log(`LineHistoryNode.onRepoChanged(${e.changes.join()}); triggering node refresh`);
void this.triggerChange();
void (this.parent ?? this).triggerChange();
}
private onRepoFileSystemChanged(e: RepositoryFileSystemChangeEvent) {
@ -255,7 +270,7 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
Logger.debug(`LineHistoryNode.onRepoFileSystemChanged(${this.uri.toString(true)}); triggering node refresh`);
void this.triggerChange();
void (this.parent ?? this).triggerChange();
}
@gate()
@ -293,6 +308,9 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
this._log = log;
this.limit = log?.count;
void this.triggerChange(false);
void (this.parent ?? this).triggerChange(false);
if (this.parent) {
this.view.triggerNodeChange(this.parent);
}
}
}

+ 2
- 2
src/views/nodes/lineHistoryTrackerNode.ts 查看文件

@ -38,7 +38,7 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
this._child = undefined;
}
getChildren(): ViewNode[] {
getChildren(): ViewNode[] | Promise<ViewNode[]> {
if (this._child == null) {
if (this.uri === unknownGitUri) {
return [
@ -59,7 +59,7 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
this._child = new LineHistoryNode(fileUri, this.view, this, this._selection!, this._editorContents);
}
return [this._child];
return this._child.getChildren();
}
getTreeItem(): TreeItem {

Loading…
取消
儲存