From b4ab012d6c0e3df9ecdca20a2a206d0c947041e5 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 10 Apr 2023 17:56:04 -0400 Subject: [PATCH] Fixes issues with commit details sha hint --- src/system/mru.ts | 24 +++++++------------- src/webviews/commitDetails/commitDetailsWebview.ts | 26 +++++----------------- 2 files changed, 13 insertions(+), 37 deletions(-) diff --git a/src/system/mru.ts b/src/system/mru.ts index d26be37..36b733a 100644 --- a/src/system/mru.ts +++ b/src/system/mru.ts @@ -13,14 +13,13 @@ export class MRU { } add(item: T): void { - const index = - this.comparator != null ? this.stack.findIndex(i => this.comparator!(item, i)) : this.stack.indexOf(item); - if (this._position > 0) { this.stack.splice(0, this._position); this._position = 0; } + const index = + this.comparator != null ? this.stack.findIndex(i => this.comparator!(item, i)) : this.stack.indexOf(item); if (index !== -1) { this.stack.splice(index, 1); } else if (this.stack.length === this.maxSize) { @@ -39,20 +38,13 @@ 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; + insert(item: T): void { + if (this._position > 0) { + this.stack.splice(0, this._position); + this._position = 0; } + this.stack.unshift(item); + this._position++; } navigate(direction: 'back' | 'forward'): T | undefined { diff --git a/src/webviews/commitDetails/commitDetailsWebview.ts b/src/webviews/commitDetails/commitDetailsWebview.ts index ed4aa2b..21e991c 100644 --- a/src/webviews/commitDetails/commitDetailsWebview.ts +++ b/src/webviews/commitDetails/commitDetailsWebview.ts @@ -184,10 +184,8 @@ export class CommitDetailsWebviewProvider implements WebviewProvider