From dbdb77c2c11382c5b109f3128819afd3115e9ece Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sun, 14 May 2017 02:18:22 -0400 Subject: [PATCH] Fixes left alignment priority Adds live update support for status bar alignment Adds values to description Adds to README --- README.md | 1 + package.json | 2 +- src/blameActiveLineController.ts | 10 ++++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 48d4ace..f7d98c0 100644 --- a/README.md +++ b/README.md @@ -209,6 +209,7 @@ GitLens is highly customizable and provides many configuration settings to allow |`gitlens.statusBar.command`|"Specifies the command executed when the blame status bar item is clicked. `gitlens.toggleBlame` - toggles blame annotations. `gitlens.showBlameHistory` - opens the blame history explorer. `gitlens.showFileHistory` - opens the file history explorer. `gitlens.diffWithPrevious` - compares the current committed file with the previous commit. `gitlens.toggleCodeLens` - toggles Git code lens. `gitlens.showQuickCommitDetails` - shows a commit details quick pick. `gitlens.showQuickCommitFileDetails` - shows a commit file details quick pick. `gitlens.showQuickFileHistory` - shows a file history quick pick. `gitlens.showQuickRepoHistory` - shows a branch history quick pick |`gitlens.statusBar.date`|Specifies whether and how the commit date will be shown in the blame status bar. `off` - no date. `relative` - relative date (e.g. 1 day ago). `absolute` - date format specified by `gitlens.statusBar.dateFormat` |`gitlens.statusBar.dateFormat`|Specifies the date format of how absolute dates will be shown in the blame status bar. See https://momentjs.com/docs/#/displaying/format/ for valid formats +|`gitlens.statusBar.alignment`|Specifies the blame alignment in the status bar. `left` - align to the left, `right` - align to the right |`gitlens.insiders`|Opts into the insiders channel -- provides access to upcoming features ## Known Issues diff --git a/package.json b/package.json index 1314d54..c13513a 100644 --- a/package.json +++ b/package.json @@ -309,7 +309,7 @@ "left", "right" ], - "description": "Specifies the blame alignment in the status bar" + "description": "Specifies the blame alignment in the status bar. `left` - align to the left, `right` - align to the right" }, "gitlens.advanced.caching.enabled": { "type": "boolean", diff --git a/src/blameActiveLineController.ts b/src/blameActiveLineController.ts index f02b45b..f5819d9 100644 --- a/src/blameActiveLineController.ts +++ b/src/blameActiveLineController.ts @@ -61,11 +61,13 @@ export class BlameActiveLineController extends Disposable { if (!Objects.areEquivalent(cfg.statusBar, this._config && this._config.statusBar)) { changed = true; if (cfg.statusBar.enabled) { - // Coerce invalid configuration to the default right alignment - const useDefaultAlignment = cfg.statusBar.alignment === 'right' || cfg.statusBar.alignment !== 'left'; - const alignment = useDefaultAlignment ? StatusBarAlignment.Right : StatusBarAlignment.Left; + const alignment = cfg.statusBar.alignment !== 'left' ? StatusBarAlignment.Right : StatusBarAlignment.Left; + if (this._statusBarItem !== undefined && this._statusBarItem.alignment !== alignment) { + this._statusBarItem.dispose(); + this._statusBarItem = undefined; + } - this._statusBarItem = this._statusBarItem || window.createStatusBarItem(alignment, 1000); + this._statusBarItem = this._statusBarItem || window.createStatusBarItem(alignment, alignment === StatusBarAlignment.Right ? 1000 : 0); this._statusBarItem.command = cfg.statusBar.command; } else if (!cfg.statusBar.enabled && this._statusBarItem) {