Преглед на файлове

Adds control over annotation characters

main
Eric Amodio преди 7 години
родител
ревизия
62c5094b06
променени са 4 файла, в които са добавени 47 реда и са изтрити 8 реда
  1. +20
    -0
      package.json
  2. +15
    -6
      src/blameAnnotationFormatter.ts
  3. +6
    -0
      src/configuration.ts
  4. +6
    -2
      src/extension.ts

+ 20
- 0
package.json Целия файл

@ -88,6 +88,26 @@
],
"description": "Specifies whether and how to show blame annotations on the active line. `off` - no annotation. `inline` - adds a trailing annotation to the active line. `hover` - adds hover annotation to the active line. `both` - adds both `inline` and `hover` annotations"
},
"gitlens.blame.annotation.characters.ellipse": {
"type": "string",
"default": "\\2026",
"description": "Specifies the ellipse character to use in blame annotations"
},
"gitlens.blame.annotation.characters.indent": {
"type": "string",
"default": "\\2759",
"description": "Specifies the indent character to use in `compact` blame annotations"
},
"gitlens.blame.annotation.characters.padding": {
"type": "string",
"default": "\\00a0",
"description": "Specifies the padding character (typically a non-breaking space) to use in blame annotations"
},
"gitlens.blame.annotation.characters.separator": {
"type": "string",
"default": "\\2022",
"description": "Specifies the separator character to use in blame annotations"
},
"gitlens.codeLens.visibility": {
"type": "string",
"default": "auto",

+ 15
- 6
src/blameAnnotationFormatter.ts Целия файл

@ -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) {

+ 6
- 0
src/configuration.ts Целия файл

@ -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;
}
};
}

+ 6
- 2
src/extension.ts Целия файл

@ -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 {

Зареждане…
Отказ
Запис