From 0c706e4afcba55d1e3e7a478481dd93fc024964d Mon Sep 17 00:00:00 2001 From: Keith Daulton Date: Mon, 10 Apr 2023 17:12:39 -0400 Subject: [PATCH] Adds sha hint to commit details --- src/system/mru.ts | 16 +++++++++++ src/webviews/apps/commitDetails/commitDetails.html | 3 +++ src/webviews/apps/commitDetails/commitDetails.scss | 4 +++ src/webviews/apps/commitDetails/commitDetails.ts | 16 +++++++++++ src/webviews/commitDetails/commitDetailsWebview.ts | 31 +++++++++++++++++++--- src/webviews/commitDetails/protocol.ts | 1 + 6 files changed, 68 insertions(+), 3 deletions(-) diff --git a/src/system/mru.ts b/src/system/mru.ts index 7d25515..d26be37 100644 --- a/src/system/mru.ts +++ b/src/system/mru.ts @@ -39,6 +39,22 @@ export class MRU { return this.stack.length > 0 ? this.stack[0] : undefined; } + insert(item: T, ref?: T): void { + const index = + ref == null + ? -1 + : this.comparator != null + ? this.stack.findIndex(i => this.comparator!(ref, i)) + : this.stack.indexOf(ref); + if (index === -1) { + this.add(item); + this._position = 1; + } else { + this.stack.splice(index, 0, item); + this._position = index + 1; + } + } + navigate(direction: 'back' | 'forward'): T | undefined { if (this.stack.length <= 1) return undefined; diff --git a/src/webviews/apps/commitDetails/commitDetails.html b/src/webviews/apps/commitDetails/commitDetails.html index 76dc6a7..6dcd2a8 100644 --- a/src/webviews/apps/commitDetails/commitDetails.html +++ b/src/webviews/apps/commitDetails/commitDetails.html @@ -118,6 +118,9 @@ title="Forward" > +