From 8a3b5d1f445abeb02bfea6db1dc6d9c3d4bc01a9 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sun, 22 Jul 2018 01:49:35 -0400 Subject: [PATCH] Changes commit results to look like search results --- src/views/nodes/commitResultsNode.ts | 36 +++++++++++------------------------- src/views/nodes/explorerNode.ts | 13 +++++++++++-- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/views/nodes/commitResultsNode.ts b/src/views/nodes/commitResultsNode.ts index 9f6e291..ee507ac 100644 --- a/src/views/nodes/commitResultsNode.ts +++ b/src/views/nodes/commitResultsNode.ts @@ -1,42 +1,28 @@ 'use strict'; import { TreeItem, TreeItemCollapsibleState } from 'vscode'; -import { GlyphChars } from '../../constants'; -import { Container } from '../../container'; -import { CommitFormatter, GitLogCommit } from '../../gitService'; -import { Strings } from '../../system'; +import { GitLogCommit } from '../../gitService'; +import { ResultsExplorer } from '../resultsExplorer'; import { CommitNode } from './commitNode'; -import { Explorer, ExplorerNode, MessageNode, ResourceType } from './explorerNode'; +import { ExplorerNode, ResourceType } from './explorerNode'; export class CommitResultsNode extends ExplorerNode { constructor( public readonly commit: GitLogCommit, - private readonly explorer: Explorer, - private readonly contextValue: ResourceType = ResourceType.Results + private readonly explorer: ResultsExplorer ) { super(commit.toGitUri()); } - async getChildren(): Promise { - const children = await new CommitNode(this.commit, this.explorer).getChildren(); - children.splice( - 0, - 0, - new MessageNode( - CommitFormatter.fromTemplate('${message}', this.commit, { truncateMessageAtNewLine: true }), - CommitFormatter.fromTemplate('${message}', this.commit) - ) - ); - return children; + getChildren(): ExplorerNode[] { + return [new CommitNode(this.commit, this.explorer)]; } - async getTreeItem(): Promise { - const label = CommitFormatter.fromTemplate( - `Commit \${sha} ${Strings.pad(GlyphChars.Dash, 1, 1)} \${authorAgoOrDate}`, - this.commit, - Container.config.defaultDateFormat + getTreeItem(): TreeItem { + const item = new TreeItem( + `1 result for commits with an id matching '${this.commit.shortSha}'`, + TreeItemCollapsibleState.Expanded ); - const item = new TreeItem(label, TreeItemCollapsibleState.Expanded); - item.contextValue = this.contextValue; + item.contextValue = ResourceType.Results; return item; } } diff --git a/src/views/nodes/explorerNode.ts b/src/views/nodes/explorerNode.ts index 9f996ec..c0774a8 100644 --- a/src/views/nodes/explorerNode.ts +++ b/src/views/nodes/explorerNode.ts @@ -1,5 +1,5 @@ 'use strict'; -import { Command, Disposable, TreeItem, TreeItemCollapsibleState } from 'vscode'; +import { Command, Disposable, ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from 'vscode'; import { GlyphChars } from '../../constants'; import { Container } from '../../container'; import { GitUri } from '../../gitService'; @@ -117,7 +117,15 @@ export abstract class ExplorerRefNode extends ExplorerNode { export class MessageNode extends ExplorerNode { constructor( private readonly message: string, - private readonly tooltip?: string + private readonly tooltip?: string, + private readonly iconPath?: + | string + | Uri + | { + light: string | Uri; + dark: string | Uri; + } + | ThemeIcon ) { super(new GitUri()); } @@ -130,6 +138,7 @@ export class MessageNode extends ExplorerNode { const item = new TreeItem(this.message, TreeItemCollapsibleState.None); item.contextValue = ResourceType.Message; item.tooltip = this.tooltip; + item.iconPath = this.iconPath; return item; } }