mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-29 17:25:20 -05:00
Adds control over annotation characters
This commit is contained in:
@@ -9,10 +9,17 @@ export const defaultRelativeDateLength = 13;
|
||||
export const defaultAuthorLength = 16;
|
||||
export const defaultMessageLength = 32;
|
||||
|
||||
export const cssEllipse = '\\2026';
|
||||
export const cssIndent = '\\02759';
|
||||
export const cssSeparator = '\\2022';
|
||||
export const cssSpace = '\\00a0';
|
||||
export let cssEllipse = '\\2026';
|
||||
export let cssIndent = '\\2759';
|
||||
export let cssSeparator = '\\2022';
|
||||
export let cssPadding = '\\00a0';
|
||||
|
||||
export function configureCssCharacters(config: IBlameConfig) {
|
||||
cssEllipse = config.annotation.characters.ellipse || cssEllipse;
|
||||
cssIndent = config.annotation.characters.indent || cssIndent;
|
||||
cssPadding = config.annotation.characters.padding || cssPadding;
|
||||
cssSeparator = config.annotation.characters.separator || cssSeparator;
|
||||
}
|
||||
|
||||
export enum BlameAnnotationFormat {
|
||||
Constrained,
|
||||
@@ -85,7 +92,8 @@ export default class BlameAnnotationFormatter {
|
||||
return `${author.substring(0, truncateTo - cssEllipse.length)}${cssEllipse}`;
|
||||
}
|
||||
|
||||
return author + `${cssSpace}`.repeat(truncateTo - author.length);
|
||||
if (force) return author; // Don't pad when just asking for the value
|
||||
return author + `${cssPadding}`.repeat(truncateTo - author.length);
|
||||
}
|
||||
|
||||
static getDate(config: IBlameConfig, commit: GitCommit, format?: string, truncate: boolean = false, force: boolean = false) {
|
||||
@@ -101,7 +109,8 @@ export default class BlameAnnotationFormatter {
|
||||
return `${date.substring(0, truncateTo - cssEllipse.length)}${cssEllipse}`;
|
||||
}
|
||||
|
||||
return date + `${cssSpace}`.repeat(truncateTo - date.length);
|
||||
if (force) return date; // Don't pad when just asking for the value
|
||||
return date + `${cssPadding}`.repeat(truncateTo - date.length);
|
||||
}
|
||||
|
||||
static getMessage(config: IBlameConfig, commit: GitCommit, truncateTo: number = 0, force: boolean = false) {
|
||||
|
||||
@@ -16,6 +16,12 @@ export interface IBlameConfig {
|
||||
date: 'off' | 'relative' | 'absolute';
|
||||
message: boolean;
|
||||
activeLine: 'off' | 'inline' | 'hover' | 'both';
|
||||
characters: {
|
||||
ellipse: string;
|
||||
indent: string;
|
||||
padding: string;
|
||||
separator: string;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { ExtensionContext, languages, window, workspace } from 'vscode';
|
||||
import BlameAnnotationController from './blameAnnotationController';
|
||||
import BlameStatusBarController from './blameStatusBarController';
|
||||
import { configureCssCharacters } from './blameAnnotationFormatter';
|
||||
import DiffLineWithPreviousCommand from './commands/diffLineWithPrevious';
|
||||
import DiffLineWithWorkingCommand from './commands/diffLineWithWorking';
|
||||
import DiffWithPreviousCommand from './commands/diffWithPrevious';
|
||||
@@ -13,7 +14,7 @@ import ShowQuickFileHistoryCommand from './commands/showQuickFileHistory';
|
||||
import ShowQuickRepoHistoryCommand from './commands/showQuickRepoHistory';
|
||||
import ToggleBlameCommand from './commands/toggleBlame';
|
||||
import ToggleCodeLensCommand from './commands/toggleCodeLens';
|
||||
import { IAdvancedConfig } from './configuration';
|
||||
import { IAdvancedConfig, IBlameConfig } from './configuration';
|
||||
import { WorkspaceState } from './constants';
|
||||
import GitContentProvider from './gitContentProvider';
|
||||
import GitProvider, { Git } from './gitProvider';
|
||||
@@ -32,7 +33,10 @@ export async function activate(context: ExtensionContext) {
|
||||
const rootPath = workspace.rootPath.replace(/\\/g, '/');
|
||||
Logger.log(`GitLens active: ${rootPath}`);
|
||||
|
||||
const gitPath = workspace.getConfiguration('gitlens').get<IAdvancedConfig>('advanced').git;
|
||||
const config = workspace.getConfiguration('gitlens');
|
||||
const gitPath = config.get<IAdvancedConfig>('advanced').git;
|
||||
|
||||
configureCssCharacters(config.get<IBlameConfig>('blame'));
|
||||
|
||||
let repoPath: string;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user