diff --git a/CHANGELOG.md b/CHANGELOG.md
index ba274b4..045780e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Adds the _Search Commits_ command to the search results inline toolbar
- Reopens the commit search when clicking on a search results without results
- Adds a _Collapse_ command to the toolbars of the _Compare_ and _Search Commits_ views
+- Adds a `gitlens.views.commitFileDescriptionFormat` setting to specify the description format of a committed file in the views
+- Adds a `gitlens.views.commitDescriptionFormat` setting to specify the description format of committed changes in the views
+- Adds a `gitlens.views.stashFileDescriptionFormat` setting to specify the description format of a stashed file in the views
+- Adds a `gitlens.views.stashDescriptionFormat` setting to specify the description format of stashed changes in the views
+- Adds a `gitlens.views.statusFileDescriptionFormat` setting to specify the description format of the status of a working or committed file in the views
### Fixed
diff --git a/README.md b/README.md
index fbd3542..9959864 100644
--- a/README.md
+++ b/README.md
@@ -805,15 +805,20 @@ See also [View Settings](#view-settings- 'Jump to the View settings')
### View Settings [#](#view-settings- 'View Settings')
-| Name | Description |
-| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `gitlens.views.avatars` | Specifies whether to show avatar images instead of commit (or status) icons in the views |
-| `gitlens.views.commitFileFormat` | Specifies the format of a committed file in the views
Available tokens
`${directory}` — directory name
`${file}` — file name
`${filePath}` — formatted file name and path
`${path}` — full file path |
-| `gitlens.views.commitFormat` | Specifies the format of committed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting
Available tokens
`${id}`— commit id
`${author}` — commit author
`${message}`— commit message
`${ago}` — relative commit date (e.g. 1 day ago)
`${date}`— formatted commit date (format specified by`gitlens.statusBar.dateFormat`)
`${agoOrDate}` — commit date specified by `gitlens.defaultDateStyle`
`${authorAgo}`— commit author, relative commit date
`${authorAgoOrDate}` — commit author, commit date specified by `gitlens.defaultDateStyle` |
-| `gitlens.views.defaultItemLimit` | Specifies the default number of items to show in a view list. Use 0 to specify no limit |
-| `gitlens.views.stashFileFormat` | Specifies the format of a stashed file in the views
Available tokens
`${directory}` — directory name
`${file}` — file name
`${filePath}` — formatted file name and path
`${path}` — full file path |
-| `gitlens.views.stashFormat` | Specifies the format of stashed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting
Available tokens
`${id}` — commit id
`${author}` — commit author
`${message}` — commit message
`${ago}` — relative commit date (e.g. 1 day ago)
`${date}`— formatted commit date (format specified by `gitlens.statusBar.dateFormat`)
`${agoOrDate}` — commit date specified by `gitlens.defaultDateStyle`
`${authorAgo}` — commit author, relative commit date
`${authorAgoOrDate}` — commit author, commit date specified by `gitlens.defaultDateStyle` |
-| `gitlens.views.statusFileFormat` | Specifies the format of the status of a working or committed file in the views
Available tokens
`${directory}` — directory name
`${file}` — file name
`${filePath}` — formatted file name and path
`${path}` — full file path
`${working}` — optional indicator if the file is uncommitted |
+| Name | Description |
+| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `gitlens.views.avatars` | Specifies whether to show avatar images instead of commit (or status) icons in the views |
+| `gitlens.views.commitFileFormat` | Specifies the format of a committed file in the views
Available tokens
`${directory}` — directory name
`${file}` — file name
`${filePath}` — formatted file name and path
`${path}` — full file path |
+| `gitlens.views.commitFileDescriptionFormat` | Specifies the description format of a committed file in the views
Available tokens
`${directory}` — directory name
`${file}` — file name
`${filePath}` — formatted file name and path
`${path}` — full file path |
+| `gitlens.views.commitFormat` | Specifies the format of committed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting
Available tokens
`${id}`— commit id
`${author}` — commit author
`${message}`— commit message
`${ago}` — relative commit date (e.g. 1 day ago)
`${date}`— formatted commit date (format specified by`gitlens.statusBar.dateFormat`)
`${agoOrDate}` — commit date specified by `gitlens.defaultDateStyle`
`${authorAgo}`— commit author, relative commit date
`${authorAgoOrDate}` — commit author, commit date specified by `gitlens.defaultDateStyle` |
+| `gitlens.views.commitDescriptionFormat` | Specifies the description format of committed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting
Available tokens
`${id}`— commit id
`${author}` — commit author
`${message}`— commit message
`${ago}` — relative commit date (e.g. 1 day ago)
`${date}`— formatted commit date (format specified by`gitlens.statusBar.dateFormat`)
`${agoOrDate}` — commit date specified by `gitlens.defaultDateStyle`
`${authorAgo}`— commit author, relative commit date
`${authorAgoOrDate}` — commit author, commit date specified by `gitlens.defaultDateStyle` |
+| `gitlens.views.defaultItemLimit` | Specifies the default number of items to show in a view list. Use 0 to specify no limit |
+| `gitlens.views.stashFileFormat` | Specifies the format of a stashed file in the views
Available tokens
`${directory}` — directory name
`${file}` — file name
`${filePath}` — formatted file name and path
`${path}` — full file path |
+| `gitlens.views.stashFileDescriptionFormat` | Specifies the description format of a stashed file in the views
Available tokens
`${directory}` — directory name
`${file}` — file name
`${filePath}` — formatted file name and path
`${path}` — full file path |
+| `gitlens.views.stashFormat` | Specifies the format of stashed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting
Available tokens
`${id}` — commit id
`${author}` — commit author
`${message}` — commit message
`${ago}` — relative commit date (e.g. 1 day ago)
`${date}`— formatted commit date (format specified by `gitlens.statusBar.dateFormat`)
`${agoOrDate}` — commit date specified by `gitlens.defaultDateStyle`
`${authorAgo}` — commit author, relative commit date
`${authorAgoOrDate}` — commit author, commit date specified by `gitlens.defaultDateStyle` |
+| `gitlens.views.stashDescriptionFormat` | Specifies the description format of stashed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting
Available tokens
`${id}` — commit id
`${author}` — commit author
`${message}` — commit message
`${ago}` — relative commit date (e.g. 1 day ago)
`${date}`— formatted commit date (format specified by `gitlens.statusBar.dateFormat`)
`${agoOrDate}` — commit date specified by `gitlens.defaultDateStyle`
`${authorAgo}` — commit author, relative commit date
`${authorAgoOrDate}` — commit author, commit date specified by `gitlens.defaultDateStyle` |
+| `gitlens.views.statusFileFormat` | Specifies the format of the status of a working or committed file in the views
Available tokens
`${directory}` — directory name
`${file}` — file name
`${filePath}` — formatted file name and path
`${path}` — full file path
`${working}` — optional indicator if the file is uncommitted |
+| `gitlens.views.statusFileDescriptionFormat` | Specifies the description format of the status of a working or committed file in the views
Available tokens
`${directory}` — directory name
`${file}` — file name
`${filePath}` — formatted file name and path
`${path}` — full file path
`${working}` — optional indicator if the file is uncommitted |
### Modes Settings [#](#modes-settings- 'Modes Settings')
diff --git a/package.json b/package.json
index b0201bb..d7ac6c0 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,7 @@
"url": "https://github.com/eamodio/vscode-gitlens.git"
},
"engines": {
- "vscode": "^1.29.0"
+ "vscode": "^1.30.0"
},
"main": "./dist/extension",
"icon": "images/gitlens-icon.png",
@@ -1207,16 +1207,28 @@
},
"gitlens.views.commitFileFormat": {
"type": "string",
- "default": "${filePath}",
+ "default": "${file}",
"markdownDescription": "Specifies the format of a committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path",
"scope": "window"
},
+ "gitlens.views.commitFileDescriptionFormat": {
+ "type": "string",
+ "default": "${directory}",
+ "markdownDescription": "Specifies the description format of a committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path",
+ "scope": "window"
+ },
"gitlens.views.commitFormat": {
"type": "string",
- "default": "${message} • ${authorAgoOrDate}${ • changes}${ (id)}",
+ "default": "${message}",
"markdownDescription": "Specifies the format of committed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
"scope": "window"
},
+ "gitlens.views.commitDescriptionFormat": {
+ "type": "string",
+ "default": "${changes • }${authorAgoOrDate}",
+ "markdownDescription": "Specifies the description format of committed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
+ "scope": "window"
+ },
"gitlens.views.compare.enabled": {
"type": "boolean",
"default": true,
@@ -1469,22 +1481,40 @@
},
"gitlens.views.stashFileFormat": {
"type": "string",
- "default": "${filePath}",
+ "default": "${file}",
"markdownDescription": "Specifies the format of a stashed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path",
"scope": "window"
},
+ "gitlens.views.stashFileDescriptionFormat": {
+ "type": "string",
+ "default": "${directory}",
+ "markdownDescription": "Specifies the description format of a stashed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path",
+ "scope": "window"
+ },
"gitlens.views.stashFormat": {
"type": "string",
- "default": "${message} • ${agoOrDate}${ • changes}",
+ "default": "${message}",
"markdownDescription": "Specifies the format of stashed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.statusBar.dateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
"scope": "window"
},
+ "gitlens.views.stashDescriptionFormat": {
+ "type": "string",
+ "default": "${changes • }${agoOrDate}",
+ "markdownDescription": "Specifies the description format of stashed changes in the views. See the [GitLens docs](https://github.com/eamodio/vscode-gitlens/wiki/Advanced-Formatting) for advanced formatting\n- Available tokens\n - `${id}` — commit id\n - `${author}` — commit author\n - `${message}` — commit message\n - `${ago}` — relative commit date (e.g. 1 day ago)\n - `${date}` — formatted commit date (format specified by `#gitlens.statusBar.dateFormat#`)\n - `${agoOrDate}` — commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` — commit author, relative commit date\n - `${authorAgoOrDate}` — commit author, commit date specified by `#gitlens.defaultDateStyle#`",
+ "scope": "window"
+ },
"gitlens.views.statusFileFormat": {
"type": "string",
- "default": "${working }${filePath}",
+ "default": "${working }${file}",
"markdownDescription": "Specifies the format of the status of a working or committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path\n - `${working}` — optional indicator if the file is uncommitted",
"scope": "window"
},
+ "gitlens.views.statusFileDescriptionFormat": {
+ "type": "string",
+ "default": "${directory}",
+ "markdownDescription": "Specifies the description format of the status of a working or committed file in the views\n- Available tokens\n - `${directory}` — directory name\n - `${file}` — file name\n - `${filePath}` — formatted file name and path\n - `${path}` — full file path\n - `${working}` — optional indicator if the file is uncommitted",
+ "scope": "window"
+ },
"gitlens.advanced.blame.customArguments": {
"type": "array",
"default": null,
diff --git a/src/ui/config.ts b/src/ui/config.ts
index d8e6a1f..2970750 100644
--- a/src/ui/config.ts
+++ b/src/ui/config.ts
@@ -339,6 +339,7 @@ export interface RepositoriesViewConfig {
branches: {
layout: ViewBranchesLayout;
};
+ compact: boolean;
enabled: boolean;
files: ViewsFilesConfig;
includeWorkingTree: boolean;
@@ -360,7 +361,9 @@ export interface ViewsConfig {
compact: boolean;
threshold: number;
};
+ commitFileDescriptionFormat: string;
commitFileFormat: string;
+ commitDescriptionFormat: string;
commitFormat: string;
compare: CompareViewConfig;
// dateFormat: string | null;
@@ -368,8 +371,11 @@ export interface ViewsConfig {
lineHistory: LineHistoryViewConfig;
repositories: RepositoriesViewConfig;
search: SearchViewConfig;
+ stashFileDescriptionFormat: string;
stashFileFormat: string;
+ stashDescriptionFormat: string;
stashFormat: string;
+ statusFileDescriptionFormat: string;
statusFileFormat: string;
}
diff --git a/src/views/nodes/branchNode.ts b/src/views/nodes/branchNode.ts
index 8496c10..82208d3 100644
--- a/src/views/nodes/branchNode.ts
+++ b/src/views/nodes/branchNode.ts
@@ -97,13 +97,14 @@ export class BranchNode extends ViewRefNode implements Pageabl
}
async getTreeItem(): Promise {
- let name = this.label;
+ const name = this.label;
let tooltip = `${this.branch.getName()}${this.current ? ' (current)' : ''}`;
let iconSuffix = '';
+ let description;
if (!this.branch.remote && this.branch.tracking !== undefined) {
if (this.view.config.showTrackingBranch) {
- name += `${this.branch.getTrackingStatus({ prefix: `${GlyphChars.Space} ` })}${GlyphChars.Space} ${
+ description = `${this.branch.getTrackingStatus({ suffix: `${GlyphChars.Space} ` })}${
GlyphChars.ArrowLeftRightLong
}${GlyphChars.Space} ${this.branch.tracking}`;
}
@@ -128,6 +129,7 @@ export class BranchNode extends ViewRefNode implements Pageabl
`${!this._root && this.current ? `${GlyphChars.Check} ${GlyphChars.Space}` : ''}${name}`,
TreeItemCollapsibleState.Collapsed
);
+ item.description = description;
item.id = this.id;
item.tooltip = tooltip;
diff --git a/src/views/nodes/commitFileNode.ts b/src/views/nodes/commitFileNode.ts
index d584654..2fdbf87 100644
--- a/src/views/nodes/commitFileNode.ts
+++ b/src/views/nodes/commitFileNode.ts
@@ -71,6 +71,7 @@ export class CommitFileNode extends ViewRefNode {
const item = new TreeItem(this.label, TreeItemCollapsibleState.None);
item.contextValue = this.resourceType;
+ item.description = this.description;
item.tooltip = this.tooltip;
if ((this._displayAs & CommitFileNodeDisplayAs.CommitIcon) === CommitFileNodeDisplayAs.CommitIcon) {
@@ -92,13 +93,30 @@ export class CommitFileNode extends ViewRefNode {
item.command = this.getCommand();
- // Only cache the label/tooltip for a single refresh
+ // Only cache the label/description/tooltip for a single refresh
this._label = undefined;
+ this._description = undefined;
this._tooltip = undefined;
return item;
}
+ private _description: string | undefined;
+ get description() {
+ if (this._description === undefined) {
+ this._description =
+ this._displayAs & CommitFileNodeDisplayAs.CommitLabel
+ ? CommitFormatter.fromTemplate(this.getCommitDescriptionTemplate(), this.commit, {
+ truncateMessageAtNewLine: true,
+ dateFormat: Container.config.defaultDateFormat
+ } as ICommitFormatOptions)
+ : StatusFileFormatter.fromTemplate(this.getCommitFileDescriptionTemplate(), this.file, {
+ relativePath: this.relativePath
+ } as IStatusFormatOptions);
+ }
+ return this._description;
+ }
+
private _folderName: string | undefined;
get folderName() {
if (this._folderName === undefined) {
@@ -165,10 +183,18 @@ export class CommitFileNode extends ViewRefNode {
return this.view.config.commitFormat;
}
+ protected getCommitDescriptionTemplate() {
+ return this.view.config.commitDescriptionFormat;
+ }
+
protected getCommitFileTemplate() {
return this.view.config.commitFileFormat;
}
+ protected getCommitFileDescriptionTemplate() {
+ return this.view.config.commitFileDescriptionFormat;
+ }
+
getCommand(): Command | undefined {
return {
title: 'Compare File with Previous Revision',
diff --git a/src/views/nodes/commitNode.ts b/src/views/nodes/commitNode.ts
index bbf96bb..1fe0c58 100644
--- a/src/views/nodes/commitNode.ts
+++ b/src/views/nodes/commitNode.ts
@@ -69,9 +69,12 @@ export class CommitNode extends ViewRefNode {
}
const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed);
-
item.contextValue =
this.branch === undefined || this.branch.current ? ResourceType.CommitOnCurrentBranch : ResourceType.Commit;
+ item.description = CommitFormatter.fromTemplate(this.view.config.commitDescriptionFormat, this.commit, {
+ truncateMessageAtNewLine: true,
+ dateFormat: Container.config.defaultDateFormat
+ } as ICommitFormatOptions);
if (this.view.config.avatars) {
item.iconPath = this.commit.getGravatarUri(Container.config.defaultGravatarsStyle);
diff --git a/src/views/nodes/common.ts b/src/views/nodes/common.ts
index f82f700..c398221 100644
--- a/src/views/nodes/common.ts
+++ b/src/views/nodes/common.ts
@@ -10,6 +10,7 @@ export class MessageNode extends ViewNode {
view: View,
parent: ViewNode,
private readonly _message: string,
+ private readonly _description?: string,
private readonly _tooltip?: string,
private readonly _iconPath?:
| string
@@ -30,6 +31,7 @@ export class MessageNode extends ViewNode {
getTreeItem(): TreeItem | Promise {
const item = new TreeItem(this._message, TreeItemCollapsibleState.None);
item.contextValue = ResourceType.Message;
+ item.description = this._description;
item.tooltip = this._tooltip;
item.iconPath = this._iconPath;
return item;
@@ -42,6 +44,7 @@ export class CommandMessageNode extends MessageNode {
parent: ViewNode,
private readonly _command: Command,
message: string,
+ description?: string,
tooltip?: string,
iconPath?:
| string
@@ -52,7 +55,7 @@ export class CommandMessageNode extends MessageNode {
}
| ThemeIcon
) {
- super(view, parent, message, tooltip, iconPath);
+ super(view, parent, message, description, tooltip, iconPath);
}
getTreeItem(): TreeItem | Promise {
diff --git a/src/views/nodes/comparePickerNode.ts b/src/views/nodes/comparePickerNode.ts
index 334fb93..bbdb110 100644
--- a/src/views/nodes/comparePickerNode.ts
+++ b/src/views/nodes/comparePickerNode.ts
@@ -2,7 +2,6 @@
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { GlyphChars } from '../../constants';
import { Container } from '../../container';
-import { Strings } from '../../system';
import { CompareView } from '../compareView';
import { CompareNode } from './compareNode';
import { ResourceType, unknownGitUri, ViewNode } from './viewNode';
@@ -23,21 +22,22 @@ export class ComparePickerNode extends ViewNode {
const selectedRef = this.parent.selectedRef;
const repoPath = selectedRef !== undefined ? selectedRef.repoPath : undefined;
- let repository = '';
+ let description;
if (repoPath !== undefined) {
if ((await Container.git.getRepositoryCount()) > 1) {
const repo = await Container.git.getRepository(repoPath);
- repository = ` ${Strings.pad(GlyphChars.Dash, 1, 1)} ${(repo && repo.formattedName) || repoPath}`;
+ description = (repo && repo.formattedName) || repoPath;
}
}
let item;
if (selectedRef === undefined) {
item = new TreeItem(
- `Compare with ${repository}`,
+ `Compare with `,
TreeItemCollapsibleState.None
);
item.contextValue = ResourceType.ComparePicker;
+ item.description = description;
item.tooltip = `Click to select branch or tag for compare${GlyphChars.Ellipsis}`;
item.command = {
title: `Select branch or tag for compare${GlyphChars.Ellipsis}`,
@@ -46,10 +46,11 @@ export class ComparePickerNode extends ViewNode {
}
else {
item = new TreeItem(
- `Compare ${selectedRef.label} with ${repository}`,
+ `Compare ${selectedRef.label} with `,
TreeItemCollapsibleState.None
);
item.contextValue = ResourceType.ComparePickerWithRef;
+ item.description = description;
item.tooltip = `Click to compare ${selectedRef.label} with${GlyphChars.Ellipsis}`;
item.command = {
title: `Compare ${selectedRef.label} with${GlyphChars.Ellipsis}`,
diff --git a/src/views/nodes/compareResultsNode.ts b/src/views/nodes/compareResultsNode.ts
index afa5f1b..8c3e2a7 100644
--- a/src/views/nodes/compareResultsNode.ts
+++ b/src/views/nodes/compareResultsNode.ts
@@ -1,6 +1,5 @@
'use strict';
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
-import { GlyphChars } from '../../constants';
import { Container } from '../../container';
import { GitService, GitUri } from '../../git/gitService';
import { Strings } from '../../system';
@@ -40,19 +39,20 @@ export class CompareResultsNode extends ViewNode {
}
async getTreeItem(): Promise {
- let repository = '';
+ let description;
if ((await Container.git.getRepositoryCount()) > 1) {
const repo = await Container.git.getRepository(this.uri.repoPath!);
- repository = ` ${Strings.pad(GlyphChars.Dash, 1, 1)} ${(repo && repo.formattedName) || this.uri.repoPath}`;
+ description = (repo && repo.formattedName) || this.uri.repoPath;
}
const item = new TreeItem(
`Comparing ${this._ref1.label ||
GitService.shortenSha(this._ref1.ref, { working: 'Working Tree' })} to ${this._ref2.label ||
- GitService.shortenSha(this._ref2.ref, { working: 'Working Tree' })}${repository}`,
+ GitService.shortenSha(this._ref2.ref, { working: 'Working Tree' })}`,
TreeItemCollapsibleState.Collapsed
);
item.contextValue = ResourceType.CompareResults;
+ item.description = description;
return item;
}
diff --git a/src/views/nodes/fileHistoryNode.ts b/src/views/nodes/fileHistoryNode.ts
index 4e5eaf8..07de670 100644
--- a/src/views/nodes/fileHistoryNode.ts
+++ b/src/views/nodes/fileHistoryNode.ts
@@ -91,20 +91,17 @@ export class FileHistoryNode extends SubscribeableViewNode {
getTreeItem(): TreeItem {
const item = new TreeItem(
- `${this.uri.getFormattedPath({
- suffix: `${
- this.uri.sha
- ? ` ${
- this.uri.sha === GitService.deletedOrMissingSha
- ? this.uri.shortSha
- : `(${this.uri.shortSha})`
- }`
- : ''
- }`
- })}`,
+ `${this.uri.getFilename()}${
+ this.uri.sha
+ ? ` ${
+ this.uri.sha === GitService.deletedOrMissingSha ? this.uri.shortSha : `(${this.uri.shortSha})`
+ }`
+ : ''
+ }`,
TreeItemCollapsibleState.Expanded
);
item.contextValue = ResourceType.FileHistory;
+ item.description = this.uri.getDirectory();
item.tooltip = `History of ${this.uri.getFilename()}\n${this.uri.getDirectory()}/${
this.uri.sha === undefined ? '' : `\n\n${this.uri.sha}`
}`;
diff --git a/src/views/nodes/lineHistoryNode.ts b/src/views/nodes/lineHistoryNode.ts
index 94f0dfe..e5b67e3 100644
--- a/src/views/nodes/lineHistoryNode.ts
+++ b/src/views/nodes/lineHistoryNode.ts
@@ -98,20 +98,17 @@ export class LineHistoryNode extends SubscribeableViewNode {
? ` #${this.selection.start.line + 1}`
: ` #${this.selection.start.line + 1}-${this.selection.end.line + 1}`;
const item = new TreeItem(
- `${this.uri.getFormattedPath({
- suffix: `${lines}${
- this.uri.sha
- ? ` ${
- this.uri.sha === GitService.deletedOrMissingSha
- ? this.uri.shortSha
- : `(${this.uri.shortSha})`
- }`
- : ''
- }`
- })}`,
+ `${this.uri.getFilename()}${lines}${
+ this.uri.sha
+ ? ` ${
+ this.uri.sha === GitService.deletedOrMissingSha ? this.uri.shortSha : `(${this.uri.shortSha})`
+ }`
+ : ''
+ }`,
TreeItemCollapsibleState.Expanded
);
item.contextValue = ResourceType.LineHistory;
+ item.description = this.uri.getDirectory();
item.tooltip = `History of ${this.uri.getFilename()}${lines}\n${this.uri.getDirectory()}/${
this.uri.sha === undefined ? '' : `\n\n${this.uri.sha}`
}`;
diff --git a/src/views/nodes/remoteNode.ts b/src/views/nodes/remoteNode.ts
index cf311c3..9ea2bb1 100644
--- a/src/views/nodes/remoteNode.ts
+++ b/src/views/nodes/remoteNode.ts
@@ -80,13 +80,12 @@ export class RemoteNode extends ViewNode {
separator = GlyphChars.Dash;
}
- const label = `${this.remote.name} ${GlyphChars.Space}${separator}${GlyphChars.Space} ${
+ const item = new TreeItem(this.remote.name, TreeItemCollapsibleState.Collapsed);
+ item.description = `${separator}${GlyphChars.Space} ${
this.remote.provider !== undefined ? this.remote.provider.name : this.remote.domain
} ${GlyphChars.Space}${GlyphChars.Dot}${GlyphChars.Space} ${this.remote.path}`;
-
- const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed);
- item.id = this.id;
item.contextValue = ResourceType.Remote;
+ item.id = this.id;
item.tooltip = `${this.remote.name}
${this.remote.path} (${this.remote.provider !== undefined ? this.remote.provider.name : this.remote.domain})`;
diff --git a/src/views/nodes/repositoryNode.ts b/src/views/nodes/repositoryNode.ts
index 47ea585..a44a992 100644
--- a/src/views/nodes/repositoryNode.ts
+++ b/src/views/nodes/repositoryNode.ts
@@ -74,7 +74,7 @@ export class RepositoryNode extends SubscribeableViewNode {
children.push(new StatusFilesNode(this.view, this, status, range));
}
- children.push(new MessageNode(this.view, this, GlyphChars.Dash.repeat(2), ''));
+ children.push(new MessageNode(this.view, this, '', GlyphChars.Dash.repeat(2), ''));
}
children.push(
@@ -89,7 +89,7 @@ export class RepositoryNode extends SubscribeableViewNode {
}
async getTreeItem(): Promise {
- let label = this.repo.formattedName || this.uri.repoPath || '';
+ const label = this.repo.formattedName || this.uri.repoPath || '';
this._lastFetched = await this.repo.getLastFetched();
@@ -98,6 +98,7 @@ export class RepositoryNode extends SubscribeableViewNode {
format: 'dddd MMMM Do, YYYY h:mm a'
});
+ let description;
let tooltip = this.repo.formattedName
? `${this.repo.formattedName}${lastFetchedTooltip}\n${this.uri.repoPath}`
: `${this.uri.repoPath}${lastFetchedTooltip}`;
@@ -119,7 +120,7 @@ export class RepositoryNode extends SubscribeableViewNode {
prefix: `${GlyphChars.Space} `
});
- label += `${Strings.pad(GlyphChars.Dash, 3, 3)}${status.branch}${upstreamStatus}${workingStatus}`;
+ description = `${status.branch}${upstreamStatus}${workingStatus}`;
iconSuffix = workingStatus ? '-blue' : '';
if (status.upstream !== undefined) {
@@ -147,14 +148,12 @@ export class RepositoryNode extends SubscribeableViewNode {
}
}
- const item = new TreeItem(
- `${label}${this.formatLastFetched({
- prefix: `${Strings.pad(GlyphChars.Dash, 4, 4)}Last fetched `
- })}`,
- TreeItemCollapsibleState.Expanded
- );
- item.id = this.id;
+ const item = new TreeItem(label, TreeItemCollapsibleState.Expanded);
item.contextValue = ResourceType.Repository;
+ item.description = `${description || ''}${this.formatLastFetched({
+ prefix: `${Strings.pad(GlyphChars.Dot, 2, 2)}Last fetched `
+ })}`;
+ item.id = this.id;
item.tooltip = tooltip;
item.iconPath = {
dark: Container.context.asAbsolutePath(`images/dark/icon-repo${iconSuffix}.svg`),
diff --git a/src/views/nodes/resultsCommitsNode.ts b/src/views/nodes/resultsCommitsNode.ts
index 3065461..080b8e1 100644
--- a/src/views/nodes/resultsCommitsNode.ts
+++ b/src/views/nodes/resultsCommitsNode.ts
@@ -1,5 +1,6 @@
'use strict';
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
+import { Container } from '../../container';
import { GitLog, GitUri } from '../../git/gitService';
import { Iterables } from '../../system';
import { View } from '../viewBase';
@@ -55,11 +56,18 @@ export class ResultsCommitsNode extends ViewNode implements PageableViewNode {
async getTreeItem(): Promise {
const { label, log } = await this.getCommitsQueryResults();
+ let description;
+ if ((await Container.git.getRepositoryCount()) > 1) {
+ const repo = await Container.git.getRepository(this.repoPath);
+ description = (repo && repo.formattedName) || this.repoPath;
+ }
+
const item = new TreeItem(
label,
log && log.count > 0 ? TreeItemCollapsibleState.Collapsed : TreeItemCollapsibleState.None
);
item.contextValue = this.type;
+ item.description = description;
return item;
}
diff --git a/src/views/nodes/resultsFileNode.ts b/src/views/nodes/resultsFileNode.ts
index 47d1a4a..efa7ef1 100644
--- a/src/views/nodes/resultsFileNode.ts
+++ b/src/views/nodes/resultsFileNode.ts
@@ -30,6 +30,7 @@ export class ResultsFileNode extends ViewNode {
getTreeItem(): TreeItem {
const item = new TreeItem(this.label, TreeItemCollapsibleState.None);
item.contextValue = ResourceType.ResultsFile;
+ item.description = this.description;
item.tooltip = StatusFileFormatter.fromTemplate('${file}\n${directory}/\n\n${status}', this.file);
const statusIcon = GitFile.getStatusIcon(this.file.status);
@@ -42,6 +43,16 @@ export class ResultsFileNode extends ViewNode {
return item;
}
+ private _description: string | undefined;
+ get description() {
+ if (this._description === undefined) {
+ this._description = StatusFileFormatter.fromTemplate('${directory}', this.file, {
+ relativePath: this.relativePath
+ } as IStatusFormatOptions);
+ }
+ return this._description;
+ }
+
private _folderName: string | undefined;
get folderName() {
if (this._folderName === undefined) {
@@ -53,7 +64,7 @@ export class ResultsFileNode extends ViewNode {
private _label: string | undefined;
get label() {
if (this._label === undefined) {
- this._label = StatusFileFormatter.fromTemplate('${filePath}', this.file, {
+ this._label = StatusFileFormatter.fromTemplate('${file}', this.file, {
relativePath: this.relativePath
} as IStatusFormatOptions);
}
@@ -67,6 +78,7 @@ export class ResultsFileNode extends ViewNode {
set relativePath(value: string | undefined) {
this._relativePath = value;
this._label = undefined;
+ this._description = undefined;
}
get priority(): number {
diff --git a/src/views/nodes/searchNode.ts b/src/views/nodes/searchNode.ts
index 92b356b..65f3c3c 100644
--- a/src/views/nodes/searchNode.ts
+++ b/src/views/nodes/searchNode.ts
@@ -1,4 +1,4 @@
-'use strict';
+'strict';
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
import { SearchCommitsCommandArgs } from '../../commands';
import { GlyphChars } from '../../constants';
@@ -30,7 +30,8 @@ export class SearchNode extends ViewNode {
...command,
arguments: [this, { searchBy: GitRepoSearchBy.Message } as SearchCommitsCommandArgs]
},
- `Search commits by message (use )`,
+ `Search commits by message`,
+ 'message-pattern',
'Click to search commits by message'
),
new CommandMessageNode(
@@ -40,7 +41,8 @@ export class SearchNode extends ViewNode {
...command,
arguments: [this, { searchBy: GitRepoSearchBy.Author } as SearchCommitsCommandArgs]
},
- `${GlyphChars.Space.repeat(4)} or, by author (use @)`,
+ `${GlyphChars.Space.repeat(4)} or, by author`,
+ '@ author-pattern',
'Click to search commits by author'
),
new CommandMessageNode(
@@ -50,7 +52,8 @@ export class SearchNode extends ViewNode {
...command,
arguments: [this, { searchBy: GitRepoSearchBy.Sha } as SearchCommitsCommandArgs]
},
- `${GlyphChars.Space.repeat(4)} or, by commit id (use #)`,
+ `${GlyphChars.Space.repeat(4)} or, by commit id`,
+ '# sha',
'Click to search commits by commit id'
),
new CommandMessageNode(
@@ -60,7 +63,8 @@ export class SearchNode extends ViewNode {
...command,
arguments: [this, { searchBy: GitRepoSearchBy.Files } as SearchCommitsCommandArgs]
},
- `${GlyphChars.Space.repeat(4)} or, by files (use :)`,
+ `${GlyphChars.Space.repeat(4)} or, by files`,
+ ': file-path/glob',
'Click to search commits by files'
),
new CommandMessageNode(
@@ -70,7 +74,8 @@ export class SearchNode extends ViewNode {
...command,
arguments: [this, { searchBy: GitRepoSearchBy.Changes } as SearchCommitsCommandArgs]
},
- `${GlyphChars.Space.repeat(4)} or, by changes (use =)`,
+ `${GlyphChars.Space.repeat(4)} or, by changes`,
+ '= pattern',
'Click to search commits by changes'
),
new CommandMessageNode(
@@ -80,7 +85,8 @@ export class SearchNode extends ViewNode {
...command,
arguments: [this, { searchBy: GitRepoSearchBy.ChangedLines } as SearchCommitsCommandArgs]
},
- `${GlyphChars.Space.repeat(4)} or, by changed lines (use ~)`,
+ `${GlyphChars.Space.repeat(4)} or, by changed lines`,
+ '~ pattern',
'Click to search commits by changed lines'
)
];
diff --git a/src/views/nodes/stashFileNode.ts b/src/views/nodes/stashFileNode.ts
index f1d8961..2a59084 100644
--- a/src/views/nodes/stashFileNode.ts
+++ b/src/views/nodes/stashFileNode.ts
@@ -17,7 +17,15 @@ export class StashFileNode extends CommitFileNode {
return this.view.config.stashFormat;
}
+ protected getCommitDescriptionTemplate() {
+ return this.view.config.stashDescriptionFormat;
+ }
+
protected getCommitFileTemplate() {
return this.view.config.stashFileFormat;
}
+
+ protected getCommitFileDescriptionTemplate() {
+ return this.view.config.stashFileDescriptionFormat;
+ }
}
diff --git a/src/views/nodes/stashNode.ts b/src/views/nodes/stashNode.ts
index 5d6632c..25fb513 100644
--- a/src/views/nodes/stashNode.ts
+++ b/src/views/nodes/stashNode.ts
@@ -56,6 +56,10 @@ export class StashNode extends ViewRefNode {
TreeItemCollapsibleState.Collapsed
);
item.id = this.id;
+ item.description = CommitFormatter.fromTemplate(this.view.config.stashDescriptionFormat, this.commit, {
+ truncateMessageAtNewLine: true,
+ dateFormat: Container.config.defaultDateFormat
+ } as ICommitFormatOptions);
item.contextValue = ResourceType.Stash;
item.tooltip = CommitFormatter.fromTemplate('${ago} (${date})\n\n${message}', this.commit, {
dateFormat: Container.config.defaultDateFormat
diff --git a/src/views/nodes/statusFileNode.ts b/src/views/nodes/statusFileNode.ts
index e1c6dd7..b898e6b 100644
--- a/src/views/nodes/statusFileNode.ts
+++ b/src/views/nodes/statusFileNode.ts
@@ -59,6 +59,7 @@ export class StatusFileNode extends ViewNode {
async getTreeItem(): Promise {
const item = new TreeItem(this.label, TreeItemCollapsibleState.None);
+ item.description = this.description;
if ((this._hasStagedChanges || this._hasUnstagedChanges) && this.commits.length === 1) {
if (this._hasStagedChanges) {
@@ -108,18 +109,37 @@ export class StatusFileNode extends ViewNode {
light: Container.context.asAbsolutePath(paths.join('images', 'light', icon))
};
}
+
item.tooltip = StatusFileFormatter.fromTemplate(
`\${file}\n\${directory}/\n\n\${status} in ${this.getChangedIn()}`,
this.file
);
}
- // Only cache the label for a single refresh
+ // Only cache the label/description for a single refresh
this._label = undefined;
+ this._description = undefined;
return item;
}
+ private _description: string | undefined;
+ get description() {
+ if (this._description === undefined) {
+ this._description = StatusFileFormatter.fromTemplate(
+ this.view.config.statusFileDescriptionFormat,
+ {
+ ...this.file,
+ commit: this.commit
+ } as GitFileWithCommit,
+ {
+ relativePath: this.relativePath
+ } as IStatusFormatOptions
+ );
+ }
+ return this._description;
+ }
+
private _folderName: string | undefined;
get folderName() {
if (this._folderName === undefined) {
@@ -163,6 +183,7 @@ export class StatusFileNode extends ViewNode {
set relativePath(value: string | undefined) {
this._relativePath = value;
this._label = undefined;
+ this._description = undefined;
}
private getChangedIn(): string {
diff --git a/src/views/searchView.ts b/src/views/searchView.ts
index c5ffe73..6d7dc16 100644
--- a/src/views/searchView.ts
+++ b/src/views/searchView.ts
@@ -1,7 +1,7 @@
'use strict';
import { commands, ConfigurationChangeEvent } from 'vscode';
import { configuration, SearchViewConfig, ViewFilesLayout, ViewsConfig } from '../configuration';
-import { CommandContext, GlyphChars, setCommandContext, WorkspaceState } from '../constants';
+import { CommandContext, setCommandContext, WorkspaceState } from '../constants';
import { Container } from '../container';
import { GitLog, GitRepoSearchBy } from '../git/gitService';
import { Functions, Strings } from '../system';
@@ -110,7 +110,6 @@ export class SearchView extends ViewBase {
await this.show();
const searchQueryFn = this.getSearchQueryFn(
- repoPath,
Container.git.getLogForSearch(repoPath, search, searchBy, {
maxCount: options.maxCount
}),
@@ -122,7 +121,7 @@ export class SearchView extends ViewBase {
);
}
- async showSearchResults(
+ showSearchResults(
repoPath: string,
search: string,
searchBy: GitRepoSearchBy,
@@ -136,8 +135,8 @@ export class SearchView extends ViewBase {
};
}
) {
- const label = await this.getSearchLabel(repoPath, options.label, results);
- const searchQueryFn = Functions.cachedOnce(this.getSearchQueryFn(repoPath, results, options), {
+ const label = this.getSearchLabel(options.label, results);
+ const searchQueryFn = Functions.cachedOnce(this.getSearchQueryFn(results, options), {
label: label,
log: results
});
@@ -147,15 +146,14 @@ export class SearchView extends ViewBase {
);
}
- private async addResults(results: ViewNode) {
+ private addResults(results: ViewNode) {
const root = this.ensureRoot();
root.addOrReplace(results, !this.keepResults);
setImmediate(() => this.reveal(results, { select: true, expand: true }));
}
- private async getSearchLabel(
- repoPath: string,
+ private getSearchLabel(
label:
| string
| {
@@ -172,21 +170,14 @@ export class SearchView extends ViewBase {
const resultsType =
label.resultsType === undefined ? { singular: 'result', plural: 'results' } : label.resultsType;
- let repository = '';
- if ((await Container.git.getRepositoryCount()) > 1) {
- const repo = await Container.git.getRepository(repoPath);
- repository = ` ${Strings.pad(GlyphChars.Dash, 1, 1)} ${(repo && repo.formattedName) || repoPath}`;
- }
-
return `${Strings.pluralize(resultsType.singular, count, {
number: truncated ? `${count}+` : undefined,
plural: resultsType.plural,
zero: 'No'
- })} for ${label.label}${repository}`;
+ })} for ${label.label}`;
}
private getSearchQueryFn(
- repoPath: string,
results: Promise | GitLog | undefined,
options: {
label:
@@ -209,7 +200,7 @@ export class SearchView extends ViewBase {
: results.query)(maxCount);
}
- const label = await this.getSearchLabel(repoPath, options.label, log);
+ const label = this.getSearchLabel(options.label, log);
return {
label: label,
log: log