From a7214496e8072d25ec927be6f0ec8ff7780e5428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl=20Thom=C3=A9?= Date: Mon, 1 Apr 2024 19:56:07 +0200 Subject: [PATCH] No hover message for uncommited or unsaved changes (#51) * 0.7.1 * Update changelog * Leave hover message empty if there is no commit * Update changelog * 0.8.0 --- CHANGELOG.md | 8 ++++++++ package-lock.json | 4 ++-- package.json | 2 +- src/lib.ts | 8 ++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe69518..c382006 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.8.0] - 2024-04-01 + +- Skip hover message for uncommitted and unsaved changes + +## [0.7.1] - 2024-04-01 + +- Lower required VS Code version to 1.78.0 + ## [0.7.0] - 2024-04-01 - Show author as "You" when line blame matches current git user diff --git a/package-lock.json b/package-lock.json index 46f9f96..80585f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "git-line-blame", - "version": "0.7.0", + "version": "0.8.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "git-line-blame", - "version": "0.7.0", + "version": "0.8.0", "license": "AGPL-3.0-only", "devDependencies": { "@types/mocha": "^10.0.6", diff --git a/package.json b/package.json index 61d725d..f96a23d 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "Git Line Blame", "description": "Display inline information in the text editor about the latest commit that edited the currently selected line", "publisher": "carlthome", - "version": "0.7.0", + "version": "0.8.0", "license": "AGPL-3.0-only", "icon": "icon.png", "engines": { diff --git a/src/lib.ts b/src/lib.ts index 5ffb59b..bc287db 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -81,6 +81,14 @@ export function formatMessage( } export function formatHoverMessage(fields: Record): string { + // Leave hover message empty if there is no commit. + const notCommitted = fields["author"] === "Not Committed Yet"; + const notSaved = fields["author"] === "External file (--contents)"; + if (notCommitted || notSaved) { + return ""; + } + + // Format the hover message by collecting commit information. const header = "| Key | Value |\n| :-- | :-- |\n"; const message = Object.entries(fields) .map(([k, v]) => {