Browse Source

Adds splatting support

main
Eric Amodio 4 years ago
parent
commit
4f5b84a81a
5 changed files with 77 additions and 71 deletions
  1. +3
    -1
      src/views/nodes/branchNode.ts
  2. +30
    -33
      src/views/nodes/fileHistoryNode.ts
  3. +4
    -1
      src/views/nodes/fileHistoryTrackerNode.ts
  4. +37
    -36
      src/views/nodes/lineHistoryNode.ts
  5. +3
    -0
      src/views/nodes/lineHistoryTrackerNode.ts

+ 3
- 1
src/views/nodes/branchNode.ts View File

@ -31,6 +31,7 @@ export class BranchNode
showCurrent: boolean;
showTracking: boolean;
};
protected splatted = true;
constructor(
uri: GitUri,
@ -145,6 +146,8 @@ export class BranchNode
}
async getTreeItem(): Promise<TreeItem> {
this.splatted = false;
const name = this.label;
let tooltip = `${this.branch.getNameWithoutRemote()}${this.current ? ' (current)' : ''}`;
let iconSuffix = '';
@ -251,7 +254,6 @@ export class BranchNode
async unstar() {
await this.branch.unstar();
void this.view.refresh(true);
// void this.parent!.triggerChange();
}
@gate()

+ 30
- 33
src/views/nodes/fileHistoryNode.ts View File

@ -25,6 +25,8 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
return `${RepositoryNode.getId(repoPath)}${this.key}(${uri})`;
}
protected splatted = true;
constructor(uri: GitUri, view: View, parent: ViewNode) {
super(uri, view, parent);
}
@ -38,6 +40,12 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
}
async getChildren(): Promise<ViewNode[]> {
void this.ensureSubscription();
this.view.titleDescription = `${this.label}${
this.parent instanceof FileHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''
}`;
const children: ViewNode[] = [];
if (this.uri.sha == null) {
@ -78,42 +86,35 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
}
}
this.view.titleDescription = `${this.uri.fileName}${
this.uri.sha
? ` ${this.uri.sha === GitRevision.deletedOrMissing ? this.uri.shortSha : `(${this.uri.shortSha})`}`
: ''
}${this.parent instanceof FileHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''}`;
void this.ensureSubscription();
if (children.length === 0) return [new MessageNode(this.view, this, 'No file history could be found.')];
return children;
}
getTreeItem(): TreeItem {
const item = new TreeItem(
`${this.uri.fileName}${
this.uri.sha
? ` ${this.uri.sha === GitRevision.deletedOrMissing ? this.uri.shortSha : `(${this.uri.shortSha})`}`
: ''
}`,
TreeItemCollapsibleState.Expanded,
);
this.splatted = false;
void this.ensureSubscription();
const label = this.label;
const item = new TreeItem(label, TreeItemCollapsibleState.Expanded);
item.contextValue = ContextValues.FileHistory;
item.description = this.uri.directory;
item.tooltip = `History of ${this.uri.fileName}\n${this.uri.directory}/${
this.uri.sha == null ? '' : `\n\n${this.uri.sha}`
}`;
this.view.titleDescription = `${this.uri.fileName}${
this.view.titleDescription = `${label}${
this.parent instanceof FileHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''
}`;
return item;
}
get label() {
return `${this.uri.fileName}${
this.uri.sha
? ` ${this.uri.sha === GitRevision.deletedOrMissing ? this.uri.shortSha : `(${this.uri.shortSha})`}`
: ''
}${this.parent instanceof FileHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''}`;
void this.ensureSubscription();
return item;
}`;
}
@debug()
@ -135,19 +136,17 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
private onRepoChanged(e: RepositoryChangeEvent) {
if (!e.changed(RepositoryChange.Heads)) return;
Logger.log(`FileHistoryNode.onRepoChanged(${e.changes.join()}); triggering node refresh`);
Logger.debug(`FileHistoryNode.onRepoChanged(${e.changes.join()}); triggering node refresh`);
void (this.parent ?? this).triggerChange(true);
void this.triggerChange();
}
private onRepoFileSystemChanged(e: RepositoryFileSystemChangeEvent) {
if (!e.uris.some(uri => uri.toString(true) === this.uri.toString(true))) return;
if (!e.uris.some(uri => uri.toString() === this.uri.toString())) return;
Logger.debug(
`FileHistoryNode${this.id}.onRepoFileSystemChanged(${this.uri.toString(true)}); triggering node refresh`,
);
Logger.debug(`FileHistoryNode.onRepoFileSystemChanged(${this.uri.toString(true)}); triggering node refresh`);
void (this.parent ?? this).triggerChange(true);
void this.triggerChange();
}
@gate()
@ -184,9 +183,7 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
this._log = log;
this.limit = log?.count;
void (this.parent ?? this).triggerChange(false);
if (this.parent) {
this.view.triggerNodeChange(this.parent);
}
// Needs to force if splatted, since the parent node will cancel the refresh (since it thinks nothing changed)
void this.triggerChange(false, this.splatted);
}
}

+ 4
- 1
src/views/nodes/fileHistoryTrackerNode.ts View File

@ -14,8 +14,9 @@ import { ContextValues, SubscribeableViewNode, unknownGitUri, ViewNode } from '.
export class FileHistoryTrackerNode extends SubscribeableViewNode<FileHistoryView> {
private _base: string | undefined;
private _fileUri: GitUri | undefined;
private _child: FileHistoryNode | undefined;
private _fileUri: GitUri | undefined;
protected splatted = true;
constructor(view: FileHistoryView) {
super(unknownGitUri, view);
@ -57,6 +58,8 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
}
getTreeItem(): TreeItem {
this.splatted = false;
const item = new TreeItem('File History', TreeItemCollapsibleState.Expanded);
item.contextValue = ContextValues.ActiveFileHistory;

+ 37
- 36
src/views/nodes/lineHistoryNode.ts View File

@ -18,7 +18,7 @@ import { insertDateMarkers } from './helpers';
import { Logger } from '../../logger';
import { LineHistoryTrackerNode } from './lineHistoryTrackerNode';
import { RepositoryNode } from './repositoryNode';
import { debug, gate, Iterables } from '../../system';
import { debug, gate, Iterables, memoize } from '../../system';
import { View } from '../viewBase';
import { ContextValues, PageableViewNode, SubscribeableViewNode, ViewNode } from './viewNode';
@ -30,6 +30,8 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
}-${selection.end.line},${selection.end.character}])`;
}
protected splatted = true;
constructor(
uri: GitUri,
view: View,
@ -49,6 +51,12 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
}
async getChildren(): Promise<ViewNode[]> {
void this.ensureSubscription();
this.view.titleDescription = `${this.label}${
this.parent instanceof LineHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''
}`;
const children: ViewNode[] = [];
let selection = this.selection;
@ -199,47 +207,42 @@ 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.titleDescription = `${this.uri.fileName}${lines}${
this.uri.sha
? ` ${this.uri.sha === GitRevision.deletedOrMissing ? this.uri.shortSha : `(${this.uri.shortSha})`}`
: ''
}${this.parent instanceof LineHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''}`;
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}`;
const item = new TreeItem(
`${this.uri.fileName}${lines}${
this.uri.sha
? ` ${this.uri.sha === GitRevision.deletedOrMissing ? this.uri.shortSha : `(${this.uri.shortSha})`}`
: ''
}`,
TreeItemCollapsibleState.Expanded,
);
this.splatted = false;
void this.ensureSubscription();
const label = this.label;
const item = new TreeItem(label, TreeItemCollapsibleState.Expanded);
item.contextValue = ContextValues.LineHistory;
item.description = this.uri.directory;
item.tooltip = `History of ${this.uri.fileName}${lines}\n${this.uri.directory}/${
item.tooltip = `History of ${this.uri.fileName}${this.lines}\n${this.uri.directory}/${
this.uri.sha == null ? '' : `\n\n${this.uri.sha}`
}${this.parent instanceof LineHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''}`;
}`;
void this.ensureSubscription();
this.view.titleDescription = `${label}${
this.parent instanceof LineHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''
}`;
this.view.titleDescription = `${this.uri.fileName}${lines}${
return item;
}
get label() {
return `${this.uri.fileName}${this.lines}${
this.uri.sha
? ` ${this.uri.sha === GitRevision.deletedOrMissing ? this.uri.shortSha : `(${this.uri.shortSha})`}`
: ''
}`;
return item;
}
@memoize()
get lines() {
return this.selection.isSingleLine
? `:${this.selection.start.line + 1}`
: `:${this.selection.start.line + 1}-${this.selection.end.line + 1}`;
}
@debug()
@ -261,17 +264,17 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
private onRepoChanged(e: RepositoryChangeEvent) {
if (!e.changed(RepositoryChange.Heads)) return;
Logger.log(`LineHistoryNode.onRepoChanged(${e.changes.join()}); triggering node refresh`);
Logger.debug(`LineHistoryNode.onRepoChanged(${e.changes.join()}); triggering node refresh`);
void (this.parent ?? this).triggerChange();
void this.triggerChange();
}
private onRepoFileSystemChanged(e: RepositoryFileSystemChangeEvent) {
if (!e.uris.some(uri => uri.toString(true) === this.uri.toString(true))) return;
if (!e.uris.some(uri => uri.toString() === this.uri.toString())) return;
Logger.debug(`LineHistoryNode.onRepoFileSystemChanged(${this.uri.toString(true)}); triggering node refresh`);
void (this.parent ?? this).triggerChange();
void this.triggerChange();
}
@gate()
@ -309,9 +312,7 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
this._log = log;
this.limit = log?.count;
void (this.parent ?? this).triggerChange(false);
if (this.parent) {
this.view.triggerNodeChange(this.parent);
}
// Needs to force if splatted, since the parent node will cancel the refresh (since it thinks nothing changed)
void this.triggerChange(false, this.splatted);
}
}

+ 3
- 0
src/views/nodes/lineHistoryTrackerNode.ts View File

@ -19,6 +19,7 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
private _child: LineHistoryNode | undefined;
private _editorContents: string | undefined;
private _selection: Selection | undefined;
protected splatted = true;
constructor(view: LineHistoryView | FileHistoryView) {
super(unknownGitUri, view);
@ -63,6 +64,8 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
}
getTreeItem(): TreeItem {
this.splatted = false;
const item = new TreeItem('Line History', TreeItemCollapsibleState.Expanded);
item.contextValue = ContextValues.ActiveLineHistory;

Loading…
Cancel
Save