Adds default date format

This commit is contained in:
Eric Amodio
2017-06-12 11:06:56 -04:00
parent 64ae82075e
commit 6f3441a9e7
11 changed files with 45 additions and 23 deletions

View File

@@ -59,8 +59,8 @@ export class Annotations {
} as DecorationOptions;
}
static detailsHover(commit: GitCommit): DecorationOptions {
const message = CommitFormatter.toHoverAnnotation(commit);
static detailsHover(commit: GitCommit, dateFormat: string | null): DecorationOptions {
const message = CommitFormatter.toHoverAnnotation(commit, dateFormat);
return {
hoverMessage: message
} as DecorationOptions;
@@ -127,9 +127,9 @@ export class Annotations {
} as IRenderOptions;
}
static hover(commit: GitCommit, renderOptions: IRenderOptions, heatmap: boolean): DecorationOptions {
static hover(commit: GitCommit, renderOptions: IRenderOptions, heatmap: boolean, dateFormat: string | null): DecorationOptions {
return {
hoverMessage: CommitFormatter.toHoverAnnotation(commit),
hoverMessage: CommitFormatter.toHoverAnnotation(commit, dateFormat),
renderOptions: heatmap ? { before: { ...renderOptions.before } } : undefined
} as DecorationOptions;
}

View File

@@ -25,7 +25,7 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
}, {} as { [token: string]: ICommitFormatOptions });
const options: ICommitFormatOptions = {
dateFormat: cfg.dateFormat,
dateFormat: cfg.dateFormat === null ? this._config.defaultDateFormat : cfg.dateFormat,
tokenOptions: tokenOptions
};
@@ -33,6 +33,7 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
const offset = this.uri.offset;
let previousLine: string | undefined = undefined;
const renderOptions = Annotations.gutterRenderOptions(this._config.theme, cfg.heatmap);
const dateFormat = this._config.defaultDateFormat;
const decorations: DecorationOptions[] = [];
@@ -58,7 +59,7 @@ export class GutterBlameAnnotationProvider extends BlameAnnotationProviderBase {
decorations.push(gutter);
if (cfg.hover.details) {
const details = Annotations.detailsHover(commit);
const details = Annotations.detailsHover(commit, dateFormat);
details.range = cfg.hover.wholeLine
? this.editor.document.validateRange(new Range(line, 0, line, endOfLineIndex))
: gutter.range;

View File

@@ -18,6 +18,7 @@ export class HoverBlameAnnotationProvider extends BlameAnnotationProviderBase {
const now = moment();
const offset = this.uri.offset;
const renderOptions = Annotations.hoverRenderOptions(this._config.theme, cfg.heatmap);
const dateFormat = this._config.defaultDateFormat;
const decorations: DecorationOptions[] = [];
@@ -27,7 +28,7 @@ export class HoverBlameAnnotationProvider extends BlameAnnotationProviderBase {
const line = l.line + offset;
const hover = Annotations.hover(commit, renderOptions, cfg.heatmap.enabled);
const hover = Annotations.hover(commit, renderOptions, cfg.heatmap.enabled, dateFormat);
const endIndex = cfg.wholeLine ? endOfLineIndex : this.editor.document.lineAt(line).firstNonWhitespaceCharacterIndex;
hover.range = this.editor.document.validateRange(new Range(line, 0, line, endIndex));

View File

@@ -21,6 +21,7 @@ export class RecentChangesAnnotationProvider extends AnnotationProviderBase {
if (diff === undefined) return false;
const cfg = this._config.annotations.file.recentChanges;
const dateFormat = this._config.defaultDateFormat;
const decorators: DecorationOptions[] = [];
@@ -42,7 +43,7 @@ export class RecentChangesAnnotationProvider extends AnnotationProviderBase {
if (cfg.hover.details) {
decorators.push({
hoverMessage: CommitFormatter.toHoverAnnotation(commit),
hoverMessage: CommitFormatter.toHoverAnnotation(commit, dateFormat),
range: range
} as DecorationOptions);
}