Skip to content

Commit 8a3b5d1

Browse files
committed
Changes commit results to look like search results
1 parent 89523f7 commit 8a3b5d1

File tree

2 files changed

+22
-27
lines changed

2 files changed

+22
-27
lines changed
Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,28 @@
11
'use strict';
22
import { TreeItem, TreeItemCollapsibleState } from 'vscode';
3-
import { GlyphChars } from '../../constants';
4-
import { Container } from '../../container';
5-
import { CommitFormatter, GitLogCommit } from '../../gitService';
6-
import { Strings } from '../../system';
3+
import { GitLogCommit } from '../../gitService';
4+
import { ResultsExplorer } from '../resultsExplorer';
75
import { CommitNode } from './commitNode';
8-
import { Explorer, ExplorerNode, MessageNode, ResourceType } from './explorerNode';
6+
import { ExplorerNode, ResourceType } from './explorerNode';
97

108
export class CommitResultsNode extends ExplorerNode {
119
constructor(
1210
public readonly commit: GitLogCommit,
13-
private readonly explorer: Explorer,
14-
private readonly contextValue: ResourceType = ResourceType.Results
11+
private readonly explorer: ResultsExplorer
1512
) {
1613
super(commit.toGitUri());
1714
}
1815

19-
async getChildren(): Promise<ExplorerNode[]> {
20-
const children = await new CommitNode(this.commit, this.explorer).getChildren();
21-
children.splice(
22-
0,
23-
0,
24-
new MessageNode(
25-
CommitFormatter.fromTemplate('${message}', this.commit, { truncateMessageAtNewLine: true }),
26-
CommitFormatter.fromTemplate('${message}', this.commit)
27-
)
28-
);
29-
return children;
16+
getChildren(): ExplorerNode[] {
17+
return [new CommitNode(this.commit, this.explorer)];
3018
}
3119

32-
async getTreeItem(): Promise<TreeItem> {
33-
const label = CommitFormatter.fromTemplate(
34-
`Commit \${sha} ${Strings.pad(GlyphChars.Dash, 1, 1)} \${authorAgoOrDate}`,
35-
this.commit,
36-
Container.config.defaultDateFormat
20+
getTreeItem(): TreeItem {
21+
const item = new TreeItem(
22+
`1 result for commits with an id matching '${this.commit.shortSha}'`,
23+
TreeItemCollapsibleState.Expanded
3724
);
38-
const item = new TreeItem(label, TreeItemCollapsibleState.Expanded);
39-
item.contextValue = this.contextValue;
25+
item.contextValue = ResourceType.Results;
4026
return item;
4127
}
4228
}

src/views/nodes/explorerNode.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
import { Command, Disposable, TreeItem, TreeItemCollapsibleState } from 'vscode';
2+
import { Command, Disposable, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode';
33
import { GlyphChars } from '../../constants';
44
import { Container } from '../../container';
55
import { GitUri } from '../../gitService';
@@ -117,7 +117,15 @@ export abstract class ExplorerRefNode extends ExplorerNode {
117117
export class MessageNode extends ExplorerNode {
118118
constructor(
119119
private readonly message: string,
120-
private readonly tooltip?: string
120+
private readonly tooltip?: string,
121+
private readonly iconPath?:
122+
| string
123+
| Uri
124+
| {
125+
light: string | Uri;
126+
dark: string | Uri;
127+
}
128+
| ThemeIcon
121129
) {
122130
super(new GitUri());
123131
}
@@ -130,6 +138,7 @@ export class MessageNode extends ExplorerNode {
130138
const item = new TreeItem(this.message, TreeItemCollapsibleState.None);
131139
item.contextValue = ResourceType.Message;
132140
item.tooltip = this.tooltip;
141+
item.iconPath = this.iconPath;
133142
return item;
134143
}
135144
}

0 commit comments

Comments
 (0)