Browse Source

Truncates messages for display in quick picks

main
Eric Amodio 7 years ago
parent
commit
77c3a4037b
6 changed files with 16 additions and 18 deletions
  1. +1
    -1
      CHANGELOG.md
  2. +1
    -5
      src/git/formatters/commit.ts
  3. +7
    -0
      src/git/models/commit.ts
  4. +4
    -4
      src/quickPicks/commitDetails.ts
  5. +2
    -2
      src/quickPicks/commitFileDetails.ts
  6. +1
    -6
      src/quickPicks/common.ts

+ 1
- 1
CHANGELOG.md View File

@ -13,13 +13,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
- Adds `gitlens.heatmap.toggleMode` setting to specify how the gutter heatmap annotations will be toggled, per file or window
- Adds `gitlens.recentChanges.toggleMode` setting to specify how the recently changed lines annotations will be toggled, per file or window
### Changed
- Renames *Compare Selected Ancestor with Working Tree* command to *Compare Ancestry with Working Tree* and removes the need to select a branch first, since all compares are done to the working tree — closes [#279](https://github.com/eamodio/vscode-gitlens/issues/279)
### Fixed
- Fixes [#294](https://github.com/eamodio/vscode-gitlens/issues/294) - Keyboard shortcuts will now default to *chorded* to avoid conflicts. FYI, only affects new installs or if you remove the `gitlens.keymap` setting)
- Fixes issue where Recent Changes annotations weren't restored properly on tab switch
- Fixes quick pick menu issue with commits with newlines in the message
## [8.0.2] - 2018-02-19
### Fixed

+ 1
- 5
src/git/formatters/commit.ts View File

@ -2,7 +2,6 @@
import { Strings } from '../../system';
import { GitCommit } from '../models/commit';
import { Formatter, IFormatOptions } from './formatter';
import { GlyphChars } from '../../constants';
export interface ICommitFormatOptions extends IFormatOptions {
truncateMessageAtNewLine?: boolean;
@ -46,10 +45,7 @@ export class CommitFormatter extends Formatter
get 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}`;
}
message = this._item.getShortMessage();
}
return this._padOrTruncate(message, this._options.tokenOptions!.message);

+ 7
- 0
src/git/models/commit.ts View File

@ -192,6 +192,13 @@ export abstract class GitCommit {
return gravatar;
}
getShortMessage(truncationSuffix: string = `${GlyphChars.Space}${GlyphChars.Ellipsis}`) {
const index = this.message.indexOf('\n');
if (index === -1) return this.message;
return `${this.message.substring(0, index)}${truncationSuffix}`;
}
async resolvePreviousFileSha(): Promise<void> {
if (this._resolvedPreviousFileSha !== undefined) return;

+ 4
- 4
src/quickPicks/commitDetails.ts View File

@ -101,7 +101,7 @@ export class CommitDetailsQuickPick {
if (stash) {
items.splice(index++, 0, new CommandQuickPickItem({
label: `$(git-pull-request) Apply Stashed Changes`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} ${commit.message}`
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} ${commit.getShortMessage(`${GlyphChars.Space}$(ellipsis)`)}`
}, Commands.StashApply, [
{
confirm: true,
@ -114,7 +114,7 @@ export class CommitDetailsQuickPick {
items.splice(index++, 0, new CommandQuickPickItem({
label: `$(x) Delete Stashed Changes`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} ${commit.message}`
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} ${commit.getShortMessage(`${GlyphChars.Space}$(ellipsis)`)}`
}, Commands.StashDelete, [
{
confirm: true,
@ -179,7 +179,7 @@ export class CommitDetailsQuickPick {
items.splice(index++, 0, new CommandQuickPickItem({
label: `$(clippy) Copy Commit Message to Clipboard`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} ${commit.message}`
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} ${commit.getShortMessage(`${GlyphChars.Space}$(ellipsis)`)}`
}, Commands.CopyMessageToClipboard, [
uri,
{
@ -303,7 +303,7 @@ export class CommitDetailsQuickPick {
const pick = await window.showQuickPick(items, {
matchOnDescription: true,
matchOnDetail: true,
placeHolder: `${commit.shortSha} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${commit.author ? `${commit.author}, ` : ''}${commit.formattedDate} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${commit.message}`,
placeHolder: `${commit.shortSha} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${commit.author ? `${commit.author}, ` : ''}${commit.formattedDate} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${commit.getShortMessage(`${GlyphChars.Space}$(ellipsis)`)}`,
ignoreFocusOut: getQuickPickIgnoreFocusOut(),
onDidSelectItem: (item: QuickPickItem) => {
scope.setKeyCommand('right', item);

+ 2
- 2
src/quickPicks/commitFileDetails.ts View File

@ -156,7 +156,7 @@ export class CommitFileDetailsQuickPick {
items.push(new CommandQuickPickItem({
label: `$(clippy) Copy Commit Message to Clipboard`,
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} ${commit.message}`
description: `${Strings.pad(GlyphChars.Dash, 2, 3)} ${commit.getShortMessage(`${GlyphChars.Space}$(ellipsis)`)}`
}, Commands.CopyMessageToClipboard, [
uri,
{
@ -310,7 +310,7 @@ export class CommitFileDetailsQuickPick {
const pick = await window.showQuickPick(items, {
matchOnDescription: true,
placeHolder: `${commit.getFormattedPath()} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${isUncommitted ? `Uncommitted ${GlyphChars.ArrowRightHollow} ` : ''}${commit.shortSha} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${commit.author}, ${commit.formattedDate} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${commit.message}`,
placeHolder: `${commit.getFormattedPath()} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${isUncommitted ? `Uncommitted ${GlyphChars.ArrowRightHollow} ` : ''}${commit.shortSha} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${commit.author}, ${commit.formattedDate} ${Strings.pad(GlyphChars.Dot, 1, 1)} ${commit.getShortMessage(`${GlyphChars.Space}$(ellipsis)`)}`,
ignoreFocusOut: getQuickPickIgnoreFocusOut(),
onDidSelectItem: (item: QuickPickItem) => {
scope.setKeyCommand('right', item as KeyCommand);

+ 1
- 6
src/quickPicks/common.ts View File

@ -155,12 +155,7 @@ export class CommitQuickPickItem implements QuickPickItem {
detail: string;
constructor(public readonly commit: GitLogCommit) {
let message = commit.message;
const index = message.indexOf('\n');
if (index !== -1) {
message = `${message.substring(0, index)}${GlyphChars.Space}$(ellipsis)`;
}
const message = commit.getShortMessage(`${GlyphChars.Space}$(ellipsis)`);
if (commit.isStash) {
this.label = message;
this.description = '';

||||||
x
 
000:0
Loading…
Cancel
Save