Skip to content

Commit 689a2e9

Browse files
committed
Fixes #1895 honors short date setting on VFH
Also defaults the short date format to the system short date format
1 parent 4248354 commit 689a2e9

File tree

8 files changed

+21
-6
lines changed

8 files changed

+21
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
1818

1919
### Fixed
2020

21+
- Fixes [#1895](https://github.com/gitkraken/vscode-gitlens/issues/1895) - Honor defaultDateShortFormat setting on Visual File History
2122
- Fixes [#1890](https://github.com/gitkraken/vscode-gitlens/issues/1890) - can no longer see untracked files in stashes
2223

2324
## [12.0.1] - 2022-03-03

src/git/models/repository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export class Repository implements Disposable {
148148
}
149149

150150
if (short) {
151-
return formatDate(date, Container.instance.config.defaultDateShortFormat ?? 'MMM D, YYYY');
151+
return formatDate(date, Container.instance.config.defaultDateShortFormat ?? 'short');
152152
}
153153

154154
let format =

src/plus/webviews/timeline/protocol.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface State {
88
uri?: string;
99

1010
dateFormat: string;
11+
shortDateFormat: string;
1112
access: FeatureAccess;
1213
}
1314

src/plus/webviews/timeline/timelineWebview.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ export class TimelineWebview extends WebviewBase<State> {
204204
private async getState(current: Context): Promise<State> {
205205
const access = await this.container.git.access(PlusFeatures.Timeline);
206206
const dateFormat = this.container.config.defaultDateFormat ?? 'MMMM Do, YYYY h:mma';
207+
const shortDateFormat = this.container.config.defaultDateShortFormat ?? 'short';
207208
const period = current.period ?? defaultPeriod;
208209

209210
if (!access.allowed) {
@@ -214,6 +215,7 @@ export class TimelineWebview extends WebviewBase<State> {
214215
title: 'src/app/index.ts',
215216
uri: Uri.file('src/app/index.ts').toString(),
216217
dateFormat: dateFormat,
218+
shortDateFormat: shortDateFormat,
217219
access: access,
218220
};
219221
}
@@ -223,6 +225,7 @@ export class TimelineWebview extends WebviewBase<State> {
223225
period: period,
224226
title: 'There are no editors open that can provide file history information',
225227
dateFormat: dateFormat,
228+
shortDateFormat: shortDateFormat,
226229
access: access,
227230
};
228231
}
@@ -249,6 +252,7 @@ export class TimelineWebview extends WebviewBase<State> {
249252
title: 'No commits found for the specified time period',
250253
uri: current.uri.toString(),
251254
dateFormat: dateFormat,
255+
shortDateFormat: shortDateFormat,
252256
access: access,
253257
};
254258
}
@@ -299,6 +303,7 @@ export class TimelineWebview extends WebviewBase<State> {
299303
title: title,
300304
uri: current.uri.toString(),
301305
dateFormat: dateFormat,
306+
shortDateFormat: shortDateFormat,
302307
access: access,
303308
};
304309
}

src/plus/webviews/timeline/timelineWebviewView.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ export class TimelineWebviewView extends WebviewViewBase<State> {
197197
private async getState(current: Context): Promise<State> {
198198
const access = await this.container.git.access(PlusFeatures.Timeline);
199199
const dateFormat = this.container.config.defaultDateFormat ?? 'MMMM Do, YYYY h:mma';
200+
const shortDateFormat = this.container.config.defaultDateShortFormat ?? 'short';
200201
const period = current.period ?? defaultPeriod;
201202

202203
if (!access.allowed) {
@@ -207,6 +208,7 @@ export class TimelineWebviewView extends WebviewViewBase<State> {
207208
title: 'src/app/index.ts',
208209
uri: Uri.file('src/app/index.ts').toString(),
209210
dateFormat: dateFormat,
211+
shortDateFormat: shortDateFormat,
210212
access: access,
211213
};
212214
}
@@ -216,6 +218,7 @@ export class TimelineWebviewView extends WebviewViewBase<State> {
216218
period: period,
217219
title: 'There are no editors open that can provide file history information',
218220
dateFormat: dateFormat,
221+
shortDateFormat: shortDateFormat,
219222
access: access,
220223
};
221224
}
@@ -242,6 +245,7 @@ export class TimelineWebviewView extends WebviewViewBase<State> {
242245
title: 'No commits found for the specified time period',
243246
uri: current.uri.toString(),
244247
dateFormat: dateFormat,
248+
shortDateFormat: shortDateFormat,
245249
access: access,
246250
};
247251
}
@@ -292,6 +296,7 @@ export class TimelineWebviewView extends WebviewViewBase<State> {
292296
title: title,
293297
uri: current.uri.toString(),
294298
dateFormat: dateFormat,
299+
shortDateFormat: shortDateFormat,
295300
access: access,
296301
};
297302
}

src/webviews/apps/plus/timeline/chart.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export class TimelineChart {
3232
private readonly _indexByAuthors = new Map<string, number>();
3333

3434
private _dateFormat: string = undefined!;
35+
private _shortDateFormat: string = undefined!;
3536

3637
constructor(selector: string) {
3738
this._selector = selector;
@@ -76,6 +77,7 @@ export class TimelineChart {
7677

7778
updateChart(state: State) {
7879
this._dateFormat = state.dateFormat;
80+
this._shortDateFormat = state.shortDateFormat;
7981

8082
this._commitsByTimestamp.clear();
8183
this._authorsByIndex.clear();
@@ -269,7 +271,8 @@ export class TimelineChart {
269271
centered: true,
270272
culling: false,
271273
fit: false,
272-
format: '%-m/%-d/%Y',
274+
format: (x: number | Date) =>
275+
typeof x === 'number' ? x : formatDate(x, this._shortDateFormat ?? 'short'),
273276
multiline: false,
274277
// rotate: 15,
275278
show: false,

src/webviews/apps/settings/partials/dates.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ <h2>Dates & Times</h2>
105105
id="defaultDateShortFormat"
106106
name="defaultDateShortFormat"
107107
type="text"
108-
placeholder="defaults to MMM D, YYYY"
108+
placeholder="defaults to system short date format"
109109
data-setting
110110
data-setting-preview
111111
/>
@@ -122,7 +122,7 @@ <h2>Dates & Times</h2>
122122
<span
123123
data-setting-preview="defaultDateShortFormat"
124124
data-setting-preview-type="date"
125-
data-setting-preview-default="MMM D, YYYY"
125+
data-setting-preview-default="short"
126126
></span>
127127
</span>
128128
</div>

src/webviews/apps/welcome/welcome.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ <h2>
399399
id="defaultDateShortFormat"
400400
name="defaultDateShortFormat"
401401
type="text"
402-
placeholder="defaults to MMM D, YYYY"
402+
placeholder="defaults to system short date format"
403403
data-setting
404404
data-setting-preview
405405
/>
@@ -416,7 +416,7 @@ <h2>
416416
<span
417417
data-setting-preview="defaultDateShortFormat"
418418
data-setting-preview-type="date"
419-
data-setting-preview-default="MMM D, YYYY"
419+
data-setting-preview-default="short"
420420
></span>
421421
</span>
422422
</div>

0 commit comments

Comments
 (0)