Browse Source

Changes node labels to takes advantage of new node descriptions

main
Eric Amodio 6 years ago
parent
commit
49c7deb8bc
21 changed files with 214 additions and 91 deletions
  1. +5
    -0
      CHANGELOG.md
  2. +14
    -9
      README.md
  3. +36
    -6
      package.json
  4. +6
    -0
      src/ui/config.ts
  5. +4
    -2
      src/views/nodes/branchNode.ts
  6. +27
    -1
      src/views/nodes/commitFileNode.ts
  7. +4
    -1
      src/views/nodes/commitNode.ts
  8. +4
    -1
      src/views/nodes/common.ts
  9. +6
    -5
      src/views/nodes/comparePickerNode.ts
  10. +4
    -4
      src/views/nodes/compareResultsNode.ts
  11. +8
    -11
      src/views/nodes/fileHistoryNode.ts
  12. +8
    -11
      src/views/nodes/lineHistoryNode.ts
  13. +3
    -4
      src/views/nodes/remoteNode.ts
  14. +9
    -10
      src/views/nodes/repositoryNode.ts
  15. +8
    -0
      src/views/nodes/resultsCommitsNode.ts
  16. +13
    -1
      src/views/nodes/resultsFileNode.ts
  17. +13
    -7
      src/views/nodes/searchNode.ts
  18. +8
    -0
      src/views/nodes/stashFileNode.ts
  19. +4
    -0
      src/views/nodes/stashNode.ts
  20. +22
    -1
      src/views/nodes/statusFileNode.ts
  21. +8
    -17
      src/views/searchView.ts

+ 5
- 0
CHANGELOG.md View File

@ -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

+ 14
- 9
README.md View File

@ -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<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; 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<br /><br />Available tokens<br />`${id}`&mdash; commit id<br />`${author}` &mdash; commit author<br />`${message}`&mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}`&mdash; formatted commit date (format specified by`gitlens.statusBar.dateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}`&mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; 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<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; 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<br /><br />Available tokens<br />`${id}` &mdash; commit id<br />`${author}` &mdash; commit author<br />`${message}` &mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}`&mdash; formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}` &mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; 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<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; full file path<br />`${working}` &mdash; 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<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; full file path |
| `gitlens.views.commitFileDescriptionFormat` | Specifies the description format of a committed file in the views<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; 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<br /><br />Available tokens<br />`${id}`&mdash; commit id<br />`${author}` &mdash; commit author<br />`${message}`&mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}`&mdash; formatted commit date (format specified by`gitlens.statusBar.dateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}`&mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; 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<br /><br />Available tokens<br />`${id}`&mdash; commit id<br />`${author}` &mdash; commit author<br />`${message}`&mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}`&mdash; formatted commit date (format specified by`gitlens.statusBar.dateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}`&mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; 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<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; full file path |
| `gitlens.views.stashFileDescriptionFormat` | Specifies the description format of a stashed file in the views<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; 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<br /><br />Available tokens<br />`${id}` &mdash; commit id<br />`${author}` &mdash; commit author<br />`${message}` &mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}`&mdash; formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}` &mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; 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<br /><br />Available tokens<br />`${id}` &mdash; commit id<br />`${author}` &mdash; commit author<br />`${message}` &mdash; commit message<br />`${ago}` &mdash; relative commit date (e.g. 1 day ago)<br />`${date}`&mdash; formatted commit date (format specified by `gitlens.statusBar.dateFormat`)<br />`${agoOrDate}` &mdash; commit date specified by `gitlens.defaultDateStyle`<br />`${authorAgo}` &mdash; commit author, relative commit date<br />`${authorAgoOrDate}` &mdash; 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<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; full file path<br />`${working}` &mdash; 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<br /><br />Available tokens<br />`${directory}` &mdash; directory name<br />`${file}` &mdash; file name<br />`${filePath}` &mdash; formatted file name and path<br />`${path}` &mdash; full file path<br />`${working}` &mdash; optional indicator if the file is uncommitted |
### Modes Settings [#](#modes-settings- 'Modes Settings')

+ 36
- 6
package.json View File

@ -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}` &mdash; directory name\n - `${file}` &mdash; file name\n - `${filePath}` &mdash; formatted file name and path\n - `${path}` &mdash; 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}` &mdash; directory name\n - `${file}` &mdash; file name\n - `${filePath}` &mdash; formatted file name and path\n - `${path}` &mdash; 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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; 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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.defaultDateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; 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}` &mdash; directory name\n - `${file}` &mdash; file name\n - `${filePath}` &mdash; formatted file name and path\n - `${path}` &mdash; 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}` &mdash; directory name\n - `${file}` &mdash; file name\n - `${filePath}` &mdash; formatted file name and path\n - `${path}` &mdash; 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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.statusBar.dateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; 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}` &mdash; commit id\n - `${author}` &mdash; commit author\n - `${message}` &mdash; commit message\n - `${ago}` &mdash; relative commit date (e.g. 1 day ago)\n - `${date}` &mdash; formatted commit date (format specified by `#gitlens.statusBar.dateFormat#`)\n - `${agoOrDate}` &mdash; commit date specified by `#gitlens.defaultDateStyle#`\n - `${authorAgo}` &mdash; commit author, relative commit date\n - `${authorAgoOrDate}` &mdash; 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}` &mdash; directory name\n - `${file}` &mdash; file name\n - `${filePath}` &mdash; formatted file name and path\n - `${path}` &mdash; full file path\n - `${working}` &mdash; 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}` &mdash; directory name\n - `${file}` &mdash; file name\n - `${filePath}` &mdash; formatted file name and path\n - `${path}` &mdash; full file path\n - `${working}` &mdash; optional indicator if the file is uncommitted",
"scope": "window"
},
"gitlens.advanced.blame.customArguments": {
"type": "array",
"default": null,

+ 6
- 0
src/ui/config.ts View File

@ -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;
}

+ 4
- 2
src/views/nodes/branchNode.ts View File

@ -97,13 +97,14 @@ export class BranchNode extends ViewRefNode implements Pageabl
}
async getTreeItem(): Promise<TreeItem> {
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;

+ 27
- 1
src/views/nodes/commitFileNode.ts View File

@ -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',

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

@ -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);

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

@ -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<TreeItem> {
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<TreeItem> {

+ 6
- 5
src/views/nodes/comparePickerNode.ts View File

@ -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 <branch, tag, or ref> with <branch, tag, or ref>${repository}`,
`Compare <branch, tag, or ref> with <branch, tag, or ref>`,
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 <branch, tag, or ref>${repository}`,
`Compare ${selectedRef.label} with <branch, tag, or ref>`,
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}`,

+ 4
- 4
src/views/nodes/compareResultsNode.ts View File

@ -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<TreeItem> {
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;
}

+ 8
- 11
src/views/nodes/fileHistoryNode.ts View File

@ -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}`
}`;

+ 8
- 11
src/views/nodes/lineHistoryNode.ts View File

@ -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}`
}`;

+ 3
- 4
src/views/nodes/remoteNode.ts View File

@ -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})`;

+ 9
- 10
src/views/nodes/repositoryNode.ts View File

@ -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<TreeItem> {
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`),

+ 8
- 0
src/views/nodes/resultsCommitsNode.ts View File

@ -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<TreeItem> {
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;
}

+ 13
- 1
src/views/nodes/resultsFileNode.ts View File

@ -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 {

+ 13
- 7
src/views/nodes/searchNode.ts View File

@ -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 <message-pattern>)`,
`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 @<author-pattern>)`,
`${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 #<sha>)`,
`${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 :<file-path/glob>)`,
`${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 =<pattern>)`,
`${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 ~<pattern>)`,
`${GlyphChars.Space.repeat(4)} or, by changed lines`,
'~ pattern',
'Click to search commits by changed lines'
)
];

+ 8
- 0
src/views/nodes/stashFileNode.ts View File

@ -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;
}
}

+ 4
- 0
src/views/nodes/stashNode.ts View File

@ -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

+ 22
- 1
src/views/nodes/statusFileNode.ts View File

@ -59,6 +59,7 @@ export class StatusFileNode extends ViewNode {
async getTreeItem(): Promise<TreeItem> {
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 {

+ 8
- 17
src/views/searchView.ts View File

@ -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> | 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

Loading…
Cancel
Save