Skip to content

Commit

Permalink
Adopts new treeview description property
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Oct 11, 2020
1 parent c168fbf commit acbe1d4
Show file tree
Hide file tree
Showing 10 changed files with 175 additions and 195 deletions.
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"url": "https://github.com/eamodio/vscode-gitlens.git"
},
"engines": {
"vscode": "^1.49.0"
"vscode": "^1.50.0"
},
"main": "./dist/gitlens",
"icon": "images/gitlens-icon.png",
Expand Down Expand Up @@ -7822,9 +7822,9 @@
"@types/lodash-es": "4.17.3",
"@types/node": "12.12.62",
"@types/sortablejs": "1.10.6",
"@types/vscode": "1.49.0",
"@typescript-eslint/eslint-plugin": "4.3.0",
"@typescript-eslint/parser": "4.3.0",
"@types/vscode": "1.50.0",
"@typescript-eslint/eslint-plugin": "4.4.0",
"@typescript-eslint/parser": "4.4.0",
"circular-dependency-plugin": "5.2.0",
"clean-webpack-plugin": "3.0.0",
"csp-html-webpack-plugin": "4.0.0",
Expand All @@ -7838,14 +7838,14 @@
"html-webpack-plugin": "4.5.0",
"html-webpack-skip-assets-plugin": "0.0.2",
"imagemin-webpack-plugin": "2.4.2",
"mini-css-extract-plugin": "0.11.2",
"mini-css-extract-plugin": "1.0.0",
"node-sass": "4.14.1",
"prettier": "2.1.2",
"sass-loader": "10.0.2",
"terser-webpack-plugin": "4.2.2",
"sass-loader": "10.0.3",
"terser-webpack-plugin": "4.2.3",
"ts-loader": "8.0.4",
"typescript": "4.0.3",
"vsce": "1.80.0",
"vsce": "1.81.1",
"webpack": "4.44.2",
"webpack-bundle-analyzer": "3.9.0",
"webpack-cli": "3.3.12"
Expand Down
4 changes: 2 additions & 2 deletions src/views/commitsView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ export class CommitsViewNode extends ViewNode<CommitsView> {
const branch = await child.repo.getBranch();
if (branch != null) {
const status = branch.getTrackingStatus();
this.view.titleDescription = `${branch.name}${status ? ` ${GlyphChars.Dot} ${status}` : ''}`;
this.view.description = `${status ? `${status} ${GlyphChars.Dot} ` : ''}${branch.name}`;
} else {
this.view.titleDescription = undefined;
this.view.description = undefined;
}

return child.getChildren();
Expand Down
9 changes: 3 additions & 6 deletions src/views/fileHistoryView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,12 @@ export class FileHistoryView extends ViewBase<FileHistoryTrackerNode | LineHisto
void setCommandContext(CommandContext.ViewsFileHistoryEditorFollowing, enabled);
this.root?.setEditorFollowing(enabled);

if (this.titleDescription?.endsWith(pinnedSuffix)) {
if (this.description?.endsWith(pinnedSuffix)) {
if (enabled) {
this.titleDescription = this.titleDescription.substr(
0,
this.titleDescription.length - pinnedSuffix.length,
);
this.description = this.description.substr(0, this.description.length - pinnedSuffix.length);
}
} else if (!enabled) {
this.titleDescription += pinnedSuffix;
this.description += pinnedSuffix;
}
}

Expand Down
9 changes: 3 additions & 6 deletions src/views/lineHistoryView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,12 @@ export class LineHistoryView extends ViewBase<LineHistoryTrackerNode, LineHistor
void setCommandContext(CommandContext.ViewsLineHistoryEditorFollowing, enabled);
this.root?.setEditorFollowing(enabled);

if (this.titleDescription?.endsWith(pinnedSuffix)) {
if (this.description?.endsWith(pinnedSuffix)) {
if (enabled) {
this.titleDescription = this.titleDescription.substr(
0,
this.titleDescription.length - pinnedSuffix.length,
);
this.description = this.description.substr(0, this.description.length - pinnedSuffix.length);
}
} else if (!enabled) {
this.titleDescription += pinnedSuffix;
this.description += pinnedSuffix;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/views/nodes/fileHistoryNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
}

async getChildren(): Promise<ViewNode[]> {
this.view.titleDescription = `${this.label}${
this.view.description = `${this.label}${
this.parent instanceof FileHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''
}`;

Expand Down Expand Up @@ -99,7 +99,7 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
this.uri.sha == null ? '' : `\n\n${this.uri.sha}`
}`;

this.view.titleDescription = `${label}${
this.view.description = `${label}${
this.parent instanceof FileHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''
}`;

Expand Down
2 changes: 1 addition & 1 deletion src/views/nodes/fileHistoryTrackerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode<FileHistoryVie
getChildren(): ViewNode[] | Promise<ViewNode[]> {
if (this._child == null) {
if (this._fileUri == null && this.uri === unknownGitUri) {
this.view.titleDescription = undefined;
this.view.description = undefined;

return [
new MessageNode(
Expand Down
4 changes: 2 additions & 2 deletions src/views/nodes/lineHistoryNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
}

async getChildren(): Promise<ViewNode[]> {
this.view.titleDescription = `${this.label}${
this.view.description = `${this.label}${
this.parent instanceof LineHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''
}`;

Expand Down Expand Up @@ -220,7 +220,7 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
this.uri.sha == null ? '' : `\n\n${this.uri.sha}`
}`;

this.view.titleDescription = `${label}${
this.view.description = `${label}${
this.parent instanceof LineHistoryTrackerNode && !this.parent.followingEditor ? ' (pinned)' : ''
}`;

Expand Down
2 changes: 1 addition & 1 deletion src/views/nodes/lineHistoryTrackerNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode<LineHistoryVie
getChildren(): ViewNode[] | Promise<ViewNode[]> {
if (this._child == null) {
if (this.uri === unknownGitUri) {
this.view.titleDescription = undefined;
this.view.description = undefined;

return [
new MessageNode(
Expand Down
42 changes: 10 additions & 32 deletions src/views/viewBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import { SearchView } from './searchView';
import { StashesView } from './stashesView';
import { debug, Functions, log, Promises, Strings } from '../system';
import { TagsView } from './tagsView';
import { GlyphChars } from '../constants';

export type View =
| BranchesView
Expand Down Expand Up @@ -172,37 +171,19 @@ export abstract class ViewBase<
}
set title(value: string | undefined) {
this._title = value;
this.updateTitle();
}

private _titleDescription: string | undefined;
get titleDescription(): string | undefined {
return this._titleDescription;
}
set titleDescription(value: string | undefined) {
this._titleDescription = value;
this.updateTitle();
}

private _updateTitleDebounced: (() => void) | undefined = undefined;
private updateTitle() {
if (this.tree == null) return;

if (this._updateTitleDebounced === undefined) {
this._updateTitleDebounced = Functions.debounce(this.updateTitleCore.bind(this), 100);
if (this.tree != null) {
this.tree.title = value;
}

this._updateTitleDebounced();
}

private updateTitleCore() {
if (this.tree == null) return;
if (this.tree.visible) {
this.tree.title = `${this.title}${
this.titleDescription ? ` ${GlyphChars.Dot} ${this.titleDescription}` : ''
}`;
} else {
this.tree.title = this.title;
private _description: string | undefined;
get description(): string | undefined {
return this._description;
}
set description(value: string | undefined) {
this._description = value;
if (this.tree != null) {
this.tree.description = value;
}
}

Expand Down Expand Up @@ -269,9 +250,6 @@ export abstract class ViewBase<
}

protected onVisibilityChanged(e: TreeViewVisibilityChangeEvent) {
if (this.titleDescription) {
this.updateTitleCore();
}
this._onDidChangeVisibility.fire(e);
}

Expand Down

0 comments on commit acbe1d4

Please sign in to comment.