mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-16 10:58:34 -05:00
Adds message truncation at newline
This commit is contained in:
@@ -187,7 +187,10 @@ export class Annotations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static trailing(commit: GitCommit, format: string, dateFormat: string | null, cfgTheme: IThemeConfig): DecorationOptions {
|
static trailing(commit: GitCommit, format: string, dateFormat: string | null, cfgTheme: IThemeConfig): DecorationOptions {
|
||||||
const message = CommitFormatter.fromTemplate(format, commit, dateFormat);
|
const message = CommitFormatter.fromTemplate(format, commit, {
|
||||||
|
truncateMessageAtNewLine: true,
|
||||||
|
dateFormat: dateFormat
|
||||||
|
} as ICommitFormatOptions);
|
||||||
return {
|
return {
|
||||||
renderOptions: {
|
renderOptions: {
|
||||||
after: {
|
after: {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { Commands } from './commands';
|
|||||||
import { TextEditorComparer } from './comparers';
|
import { TextEditorComparer } from './comparers';
|
||||||
import { IConfig, StatusBarCommand } from './configuration';
|
import { IConfig, StatusBarCommand } from './configuration';
|
||||||
import { DocumentSchemes, ExtensionKey } from './constants';
|
import { DocumentSchemes, ExtensionKey } from './constants';
|
||||||
import { BlameabilityChangeEvent, CommitFormatter, GitCommit, GitCommitLine, GitContextTracker, GitService, GitUri } from './gitService';
|
import { BlameabilityChangeEvent, CommitFormatter, GitCommit, GitCommitLine, GitContextTracker, GitService, GitUri, ICommitFormatOptions } from './gitService';
|
||||||
import { Logger } from './logger';
|
import { Logger } from './logger';
|
||||||
|
|
||||||
const annotationDecoration: TextEditorDecorationType = window.createTextEditorDecorationType({
|
const annotationDecoration: TextEditorDecorationType = window.createTextEditorDecorationType({
|
||||||
@@ -462,7 +462,10 @@ export class CurrentLineController extends Disposable {
|
|||||||
const cfg = this._config.statusBar;
|
const cfg = this._config.statusBar;
|
||||||
if (!cfg.enabled || this._statusBarItem === undefined) return;
|
if (!cfg.enabled || this._statusBarItem === undefined) return;
|
||||||
|
|
||||||
this._statusBarItem.text = `$(git-commit) ${CommitFormatter.fromTemplate(cfg.format, commit, cfg.dateFormat === null ? this._config.defaultDateFormat : cfg.dateFormat)}`;
|
this._statusBarItem.text = `$(git-commit) ${CommitFormatter.fromTemplate(cfg.format, commit, {
|
||||||
|
truncateMessageAtNewLine: true,
|
||||||
|
dateFormat: cfg.dateFormat === null ? this._config.defaultDateFormat : cfg.dateFormat
|
||||||
|
} as ICommitFormatOptions)}`;
|
||||||
|
|
||||||
switch (cfg.command) {
|
switch (cfg.command) {
|
||||||
case StatusBarCommand.BlameAnnotate:
|
case StatusBarCommand.BlameAnnotate:
|
||||||
|
|||||||
@@ -3,8 +3,11 @@ import { Strings } from '../../system';
|
|||||||
import { GitCommit } from '../models/commit';
|
import { GitCommit } from '../models/commit';
|
||||||
import { Formatter, IFormatOptions } from './formatter';
|
import { Formatter, IFormatOptions } from './formatter';
|
||||||
import * as moment from 'moment';
|
import * as moment from 'moment';
|
||||||
|
import { GlyphChars } from '../../constants';
|
||||||
|
|
||||||
export interface ICommitFormatOptions extends IFormatOptions {
|
export interface ICommitFormatOptions extends IFormatOptions {
|
||||||
|
truncateMessageAtNewLine?: boolean;
|
||||||
|
|
||||||
tokenOptions?: {
|
tokenOptions?: {
|
||||||
ago?: Strings.ITokenOptions;
|
ago?: Strings.ITokenOptions;
|
||||||
author?: Strings.ITokenOptions;
|
author?: Strings.ITokenOptions;
|
||||||
@@ -41,7 +44,14 @@ export class CommitFormatter extends Formatter<GitCommit, ICommitFormatOptions>
|
|||||||
}
|
}
|
||||||
|
|
||||||
get message() {
|
get message() {
|
||||||
const message = this._item.isUncommitted ? 'Uncommitted change' : this._item.message;
|
let message = this._item.isUncommitted ? 'Uncommitted change' : this._item.message;
|
||||||
|
if (this._options.truncateMessageAtNewLine) {
|
||||||
|
const index = message.indexOf('\n');
|
||||||
|
if (index !== -1) {
|
||||||
|
message = `${message.substring(0, index)}${GlyphChars.Space}${GlyphChars.Ellipsis}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return this._padOrTruncate(message, this._options.tokenOptions!.message);
|
return this._padOrTruncate(message, this._options.tokenOptions!.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Command, ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'v
|
|||||||
import { Commands, DiffWithPreviousCommandArgs } from '../commands';
|
import { Commands, DiffWithPreviousCommandArgs } from '../commands';
|
||||||
import { CommitFileNode } from './commitFileNode';
|
import { CommitFileNode } from './commitFileNode';
|
||||||
import { ExplorerNode, ResourceType } from './explorerNode';
|
import { ExplorerNode, ResourceType } from './explorerNode';
|
||||||
import { CommitFormatter, getGitStatusIcon, GitLogCommit, GitService, GitUri } from '../gitService';
|
import { CommitFormatter, getGitStatusIcon, GitLogCommit, GitService, GitUri, ICommitFormatOptions } from '../gitService';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export class CommitNode extends ExplorerNode {
|
export class CommitNode extends ExplorerNode {
|
||||||
@@ -28,7 +28,11 @@ export class CommitNode extends ExplorerNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTreeItem(): TreeItem {
|
getTreeItem(): TreeItem {
|
||||||
const item = new TreeItem(CommitFormatter.fromTemplate(this.template, this.commit, this.git.config.defaultDateFormat));
|
const item = new TreeItem(CommitFormatter.fromTemplate(this.template, this.commit, {
|
||||||
|
truncateMessageAtNewLine: true,
|
||||||
|
dataFormat: this.git.config.defaultDateFormat
|
||||||
|
} as ICommitFormatOptions));
|
||||||
|
|
||||||
if (this.commit.type === 'file') {
|
if (this.commit.type === 'file') {
|
||||||
item.collapsibleState = TreeItemCollapsibleState.None;
|
item.collapsibleState = TreeItemCollapsibleState.None;
|
||||||
item.command = this.getCommand();
|
item.command = this.getCommand();
|
||||||
@@ -55,17 +59,6 @@ export class CommitNode extends ExplorerNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCommand(): Command | undefined {
|
getCommand(): Command | undefined {
|
||||||
let allowMissingPrevious = false;
|
|
||||||
let prefix = undefined;
|
|
||||||
const status = this.commit.fileStatuses[0];
|
|
||||||
if (status.status === 'A') {
|
|
||||||
allowMissingPrevious = true;
|
|
||||||
prefix = 'added in ';
|
|
||||||
}
|
|
||||||
else if (status.status === 'D') {
|
|
||||||
prefix = 'deleted in ';
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
title: 'Compare File with Previous Revision',
|
title: 'Compare File with Previous Revision',
|
||||||
command: Commands.DiffWithPrevious,
|
command: Commands.DiffWithPrevious,
|
||||||
@@ -77,9 +70,7 @@ export class CommitNode extends ExplorerNode {
|
|||||||
showOptions: {
|
showOptions: {
|
||||||
preserveFocus: true,
|
preserveFocus: true,
|
||||||
preview: true
|
preview: true
|
||||||
},
|
}
|
||||||
allowMissingPrevious: allowMissingPrevious,
|
|
||||||
rightTitlePrefix: prefix
|
|
||||||
} as DiffWithPreviousCommandArgs
|
} as DiffWithPreviousCommandArgs
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
import { Event, EventEmitter, ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
|
import { Event, EventEmitter, ExtensionContext, TreeItem, TreeItemCollapsibleState } from 'vscode';
|
||||||
import { ExplorerNode, ResourceType } from './explorerNode';
|
import { ExplorerNode, ResourceType } from './explorerNode';
|
||||||
import { CommitFormatter, GitService, GitStashCommit, GitUri } from '../gitService';
|
import { CommitFormatter, GitService, GitStashCommit, GitUri, ICommitFormatOptions } from '../gitService';
|
||||||
import { StashFileNode } from './stashFileNode';
|
import { StashFileNode } from './stashFileNode';
|
||||||
|
|
||||||
export class StashNode extends ExplorerNode {
|
export class StashNode extends ExplorerNode {
|
||||||
@@ -22,9 +22,10 @@ export class StashNode extends ExplorerNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getTreeItem(): TreeItem {
|
getTreeItem(): TreeItem {
|
||||||
const label = CommitFormatter.fromTemplate(this.git.config.gitExplorer.stashFormat, this.commit, this.git.config.defaultDateFormat);
|
const item = new TreeItem(CommitFormatter.fromTemplate(this.git.config.gitExplorer.stashFormat, this.commit, {
|
||||||
|
truncateMessageAtNewLine: true,
|
||||||
const item = new TreeItem(label, TreeItemCollapsibleState.Collapsed);
|
dataFormat: this.git.config.defaultDateFormat
|
||||||
|
} as ICommitFormatOptions), TreeItemCollapsibleState.Collapsed);
|
||||||
item.contextValue = this.resourceType;
|
item.contextValue = this.resourceType;
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user