Skip to content

Commit

Permalink
No hover message for uncommited or unsaved changes (#51)
Browse files Browse the repository at this point in the history
* 0.7.1

* Update changelog

* Leave hover message empty if there is no commit

* Update changelog

* 0.8.0
  • Loading branch information
carlthome authored Apr 1, 2024
1 parent 112b286 commit a721449
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
8 changes: 8 additions & 0 deletions src/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ export function formatMessage(
}

export function formatHoverMessage(fields: Record<string, string>): 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]) => {
Expand Down

0 comments on commit a721449

Please sign in to comment.