diff --git a/CHANGELOG.md b/CHANGELOG.md index d42e536..3bb9f76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,8 +20,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p - Adds new stash behaviors to use the Source Control (commit message) input box — closes [#2081](https://github.com/gitkraken/vscode-gitlens/issues/2081) - When a stash is applied or popped and the Source Control input is empty, we will now update the Source Control input to the stash message - When stashing changes and the Source Control input is not empty, we will now default the stash message input to the Source Control input value -- Adds ability to search (Ctrl+F) for text on the Interactive Rebase Editor — closes [#2050](https://github.com/gitkraken/vscode-gitlens/issues/2050) +- Adds the ability to search (Ctrl+F) for text on the Interactive Rebase Editor — closes [#2050](https://github.com/gitkraken/vscode-gitlens/issues/2050) - Adds stats (additions & deletions) to files nodes in comparisons — closes [#2078](https://github.com/gitkraken/vscode-gitlens/issues/2078) thanks to help via [PR #2079](https://github.com/gitkraken/vscode-gitlens/pull/2079) by Nafiur Rahman Khadem ([@ShafinKhadem](https://github.com/ShafinKhadem)) +- Adds the ability to uniquely format uncommitted changes for the current line blame annotations — closes [#1987](https://github.com/gitkraken/vscode-gitlens/issues/1987) + - Adds a `gitlens.currentLine.uncommittedChangesFormat` setting to specify the uncommitted changes format of the current line blame annotation. **NOTE**: Setting this to an empty string will disable current line blame annotations for uncommitted changes ### Changed diff --git a/README.md b/README.md index 161206e..e9669a9 100644 --- a/README.md +++ b/README.md @@ -714,13 +714,14 @@ GitLens is highly customizable and provides many configuration settings to allow ## Current Line Blame Settings [#](#current-line-blame-settings- 'Current Line Blame Settings') -| Name | Description | -| ------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `gitlens.currentLine.dateFormat` | Specifies how to format absolute dates (e.g. using the `${date}` token) for the current line blame annotations. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for supported formats | -| `gitlens.currentLine.enabled` | Specifies whether to provide a blame annotation for the current line, by default. Use the _Toggle Line Blame Annotations_ command (`gitlens.toggleLineBlame`) to toggle the annotations on and off for the current window | -| `gitlens.currentLine.format` | Specifies the format of the current line blame annotation. See [_Commit Tokens_](https://github.com/gitkraken/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs. Date formatting is controlled by the `gitlens.currentLine.dateFormat` setting | -| `gitlens.currentLine.pullRequests.enabled` | Specifies whether to provide information about the Pull Request (if any) that introduced the commit in the current line blame annotation. Requires a connection to a supported remote service (e.g. GitHub) | -| `gitlens.currentLine.scrollable` | Specifies whether the current line blame annotation can be scrolled into view when it is outside the viewport. **NOTE**: Setting this to `false` will inhibit the hovers from showing over the annotation; Set `gitlens.hovers.currentLine.over` to `line` to enable the hovers to show anywhere over the line. | +| Name | Description | +| ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `gitlens.currentLine.dateFormat` | Specifies how to format absolute dates (e.g. using the `${date}` token) for the current line blame annotations. See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for supported formats | +| `gitlens.currentLine.enabled` | Specifies whether to provide a blame annotation for the current line, by default. Use the _Toggle Line Blame Annotations_ command (`gitlens.toggleLineBlame`) to toggle the annotations on and off for the current window | +| `gitlens.currentLine.format` | Specifies the format of the current line blame annotation. See [_Commit Tokens_](https://github.com/gitkraken/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs. Date formatting is controlled by the `gitlens.currentLine.dateFormat` setting | +| `gitlens.currentLine.uncommittedChangesFormat` | Specifies the uncommitted changes format of the current line blame annotation. See [_Commit Tokens_](https://github.com/gitkraken/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs. Date formatting is controlled by the `gitlens.currentLine.dateFormat` setting

**NOTE**: Setting this to an empty string will disable current line blame annotations for uncommitted changes. | +| `gitlens.currentLine.pullRequests.enabled` | Specifies whether to provide information about the Pull Request (if any) that introduced the commit in the current line blame annotation. Requires a connection to a supported remote service (e.g. GitHub) | +| `gitlens.currentLine.scrollable` | Specifies whether the current line blame annotation can be scrolled into view when it is outside the viewport. **NOTE**: Setting this to `false` will inhibit the hovers from showing over the annotation; Set `gitlens.hovers.currentLine.over` to `line` to enable the hovers to show anywhere over the line. | ## Git CodeLens Settings [#](#git-codelens-settings- 'Git CodeLens Settings') diff --git a/package.json b/package.json index 3f722cb..c6cbc36 100644 --- a/package.json +++ b/package.json @@ -250,6 +250,13 @@ "scope": "window", "order": 30 }, + "gitlens.currentLine.uncommittedChangesFormat": { + "type": "string", + "default": null, + "markdownDescription": "Specifies the uncommitted changes format of the current line blame annotation. See [_Commit Tokens_](https://github.com/gitkraken/vscode-gitlens/wiki/Custom-Formatting#commit-tokens) in the GitLens docs. Date formatting is controlled by the `#gitlens.currentLine.dateFormat#` setting.\n\n**NOTE**: Setting this to an empty string will disable current line blame annotations for uncommitted changes.", + "scope": "window", + "order": 31 + }, "gitlens.currentLine.scrollable": { "type": "boolean", "default": true, diff --git a/src/annotations/lineAnnotationController.ts b/src/annotations/lineAnnotationController.ts index cde60cb..fd3132a 100644 --- a/src/annotations/lineAnnotationController.ts +++ b/src/annotations/lineAnnotationController.ts @@ -297,11 +297,13 @@ export class LineAnnotationController implements Disposable { const decorations = []; for (const [l, commit] of commitLines) { + if (commit.isUncommitted && cfg.uncommittedChangesFormat === '') continue; + const decoration = Annotations.trailing( commit, // await GitUri.fromUri(editor.document.uri), // l, - cfg.format, + commit.isUncommitted ? cfg.uncommittedChangesFormat ?? cfg.format : cfg.format, { dateFormat: cfg.dateFormat === null ? configuration.get('defaultDateFormat') : cfg.dateFormat, getBranchAndTagTips: getBranchAndTagTips, diff --git a/src/config.ts b/src/config.ts index 757a71f..e20e2c0 100644 --- a/src/config.ts +++ b/src/config.ts @@ -28,6 +28,7 @@ export interface Config { dateFormat: string | null; enabled: boolean; format: string; + uncommittedChangesFormat: string | null; pullRequests: { enabled: boolean; }; diff --git a/src/webviews/apps/settings/partials/current-line.html b/src/webviews/apps/settings/partials/current-line.html index d36db4e..740eecc 100644 --- a/src/webviews/apps/settings/partials/current-line.html +++ b/src/webviews/apps/settings/partials/current-line.html @@ -87,6 +87,63 @@
+
+ + +
+ Example: + + +
+
+
+ + + +
+ + Example: + + +
+ +
extends Ap } const state = flatten(this.state.config); + if (this.state.customSettings != null) { + for (const [key, value] of Object.entries(this.state.customSettings)) { + state[key] = value; + } + } this.setVisibility(state); this.setEnablement(state); } @@ -507,7 +512,8 @@ export abstract class AppWithConfig extends Ap } private updatePreview(el: HTMLSpanElement, value?: string) { - switch (el.dataset.settingPreviewType) { + const previewType = el.dataset.settingPreviewType; + switch (previewType) { case 'date': { if (value === undefined) { value = this.getSettingValue(el.dataset.settingPreview!); @@ -537,13 +543,20 @@ export abstract class AppWithConfig extends Ap } break; } - case 'commit': { + case 'commit': + case 'commit-uncommitted': { if (value === undefined) { value = this.getSettingValue(el.dataset.settingPreview!); } if (!value) { value = el.dataset.settingPreviewDefault; + if (value == null) { + const lookup = el.dataset.settingPreviewDefaultLookup; + if (lookup != null) { + value = this.getSettingValue(lookup); + } + } } if (value == null) { @@ -556,7 +569,7 @@ export abstract class AppWithConfig extends Ap GenerateConfigurationPreviewCommandType, { key: el.dataset.settingPreview!, - type: 'commit', + type: previewType, format: value, }, DidGenerateConfigurationPreviewNotificationType, diff --git a/src/webviews/protocol.ts b/src/webviews/protocol.ts index 29cc99a..6bf992c 100644 --- a/src/webviews/protocol.ts +++ b/src/webviews/protocol.ts @@ -43,7 +43,7 @@ export const ExecuteCommandType = new IpcCommandType('comm export interface GenerateCommitPreviewParams { key: string; - type: 'commit'; + type: 'commit' | 'commit-uncommitted'; format: string; } diff --git a/src/webviews/webviewWithConfigBase.ts b/src/webviews/webviewWithConfigBase.ts index ad939f0..907d921 100644 --- a/src/webviews/webviewWithConfigBase.ts +++ b/src/webviews/webviewWithConfigBase.ts @@ -140,16 +140,17 @@ export abstract class WebviewWithConfigBase extends WebviewBase { onIpc(GenerateConfigurationPreviewCommandType, e, async params => { switch (params.type) { - case 'commit': { + case 'commit': + case 'commit-uncommitted': { const commit = new GitCommit( this.container, '~/code/eamodio/vscode-gitlens-demo', 'fe26af408293cba5b4bfd77306e1ac9ff7ccaef8', new GitCommitIdentity('You', 'eamodio@gmail.com', new Date('2016-11-12T20:41:00.000Z')), new GitCommitIdentity('You', 'eamodio@gmail.com', new Date('2020-11-01T06:57:21.000Z')), - 'Supercharged', + params.type === 'commit-uncommitted' ? 'Uncommitted changes' : 'Supercharged', ['3ac1d3f51d7cf5f438cc69f25f6740536ad80fef'], - 'Supercharged', + params.type === 'commit-uncommitted' ? 'Uncommitted changes' : 'Supercharged', new GitFileChange( '~/code/eamodio/vscode-gitlens-demo', 'code.ts', @@ -225,6 +226,19 @@ export abstract class WebviewWithConfigBase extends WebviewBase { update: this.container.rebaseEditor.setEnabled, }, ], + [ + 'currentLine.useUncommittedChangesFormat', + { + name: 'currentLine.useUncommittedChangesFormat', + enabled: () => configuration.get('currentLine.uncommittedChangesFormat') != null, + update: async enabled => + configuration.updateEffective( + 'currentLine.uncommittedChangesFormat', + // eslint-disable-next-line no-template-curly-in-string + enabled ? '✏️ ${ago}' : null, + ), + }, + ], ]); } return this._customSettings;