diff --git a/src/webviews/apps/commitDetails/commitDetails.html b/src/webviews/apps/commitDetails/commitDetails.html index f539a65..6f756c0 100644 --- a/src/webviews/apps/commitDetails/commitDetails.html +++ b/src/webviews/apps/commitDetails/commitDetails.html @@ -34,8 +34,11 @@ class="commit-details__commit-action" href="#" data-action="commit-show-actions" - aria-label="Show Commit Actions" - title="Show Commit Actions" + aria-label="Copy SHA +[⌥] Show Commit Actions" + title="Copy SHA +[⌥] Show Commit Actions" + > diff --git a/src/webviews/apps/commitDetails/commitDetails.scss b/src/webviews/apps/commitDetails/commitDetails.scss index 9381b1b..20facff 100644 --- a/src/webviews/apps/commitDetails/commitDetails.scss +++ b/src/webviews/apps/commitDetails/commitDetails.scss @@ -223,11 +223,11 @@ ul { display: inline-flex; justify-content: center; align-items: center; - width: 20px; + // width: 20px; height: 20px; border-radius: 0.25em; color: inherit; - padding: 2px; + padding: 0.2rem; vertical-align: text-bottom; text-decoration: none; @@ -241,6 +241,11 @@ ul { } } + &__sha { + // padding-top: 0.2rem; + margin: 0 0.5rem; + } + &__authors { flex-basis: 100%; } diff --git a/src/webviews/apps/commitDetails/commitDetails.ts b/src/webviews/apps/commitDetails/commitDetails.ts index 254aec0..c1b97d1 100644 --- a/src/webviews/apps/commitDetails/commitDetails.ts +++ b/src/webviews/apps/commitDetails/commitDetails.ts @@ -107,7 +107,12 @@ export class CommitDetailsApp extends App { return; } - this.sendCommand(CommitActionsCommandType, undefined); + if (e.altKey) { + this.sendCommand(CommitActionsCommandType, undefined); + return; + } + + void navigator.clipboard.writeText(this.state.selected.sha); } protected override onMessageReceived(e: MessageEvent) { @@ -163,6 +168,7 @@ export class CommitDetailsApp extends App { return; } + this.renderSha(); this.renderMessage(); this.renderAuthor(); this.renderStats(); @@ -174,6 +180,17 @@ export class CommitDetailsApp extends App { } } + renderSha() { + const $els = [...document.querySelectorAll('[data-region="shortsha"]')]; + if ($els.length === 0) { + return; + } + + $els.forEach($el => { + $el.textContent = this.state.selected.shortSha; + }); + } + renderChoices() { //