Browse Source

Adds CodeLens date/time format setting

main
Eric Amodio 3 years ago
parent
commit
a92c808fc6
3 changed files with 17 additions and 1 deletions
  1. +10
    -0
      package.json
  2. +6
    -1
      src/codelens/codeLensProvider.ts
  3. +1
    -0
      src/config.ts

+ 10
- 0
package.json View File

@ -430,6 +430,16 @@
"scope": "window",
"order": 72
},
"gitlens.codeLens.dateFormat": {
"type": [
"string",
"null"
],
"default": null,
"markdownDescription": "Specifies how to format absolute dates in the Git code lens. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for valid formats",
"scope": "window",
"order": 73
},
"gitlens.codeLens.scopesByLanguage": {
"deprecationMessage": "Deprecated. Use per-language `gitlens.codeLens.scopes` and `gitlens.codeLens.symbolScopes` settings instead",
"markdownDeprecationMessage": "Deprecated. Use the per-language `#gitlens.codeLens.scopes#` and `#gitlens.codeLens.symbolScopes#` settings instead"

+ 6
- 1
src/codelens/codeLensProvider.ts View File

@ -49,6 +49,7 @@ export class GitRecentChangeCodeLens extends CodeLens {
public readonly languageId: string,
public readonly symbol: DocumentSymbol | SymbolInformation,
public readonly uri: GitUri | undefined,
public readonly dateFormat: string | null,
private readonly blame: (() => GitBlameLines | undefined) | undefined,
public readonly blameRange: Range,
public readonly isFullRange: boolean,
@ -227,6 +228,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
document.languageId,
fileSymbol,
gitUri,
cfg.dateFormat,
blameForRangeFn,
blameRange,
true,
@ -408,6 +410,7 @@ export class GitCodeLensProvider implements CodeLensProvider {
document.languageId,
symbol,
gitUri,
cfg.dateFormat,
blameForRangeFn,
blameRange,
false,
@ -505,7 +508,9 @@ export class GitCodeLensProvider implements CodeLensProvider {
// }
// }
let title = `${recentCommit.author}, ${recentCommit.formattedDate}`;
let title = `${recentCommit.author}, ${
lens.dateFormat == null ? recentCommit.formattedDate : recentCommit.formatDate(lens.dateFormat)
}`;
if (this.container.config.debug) {
title += ` [${lens.languageId}: ${SymbolKind[lens.symbol.kind]}(${lens.range.start.character}-${
lens.range.end.character

+ 1
- 0
src/config.ts View File

@ -356,6 +356,7 @@ export interface CodeLensConfig {
enabled: boolean;
command: CodeLensCommand | false;
};
dateFormat: DateTimeFormat | string | null;
enabled: boolean;
includeSingleLineSymbols: boolean;
recentChange: {

Loading…
Cancel
Save