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" > +
> { $forward.setAttribute('aria-hidden', 'false'); $forward.classList.toggle('is-hidden', false); } + + const $hint = document.querySelector('[data-region="commit-hint"]'); + if ($hint == null) return; + const $hintAction = $hint.closest('.commit-action')!; + if (state.navigationStack.hint) { + $hint.innerText = state.navigationStack.hint; + $hintAction.setAttribute('aria-hidden', 'false'); + $hintAction.classList.toggle('is-hidden', false); + $hintAction.setAttribute('data-action', state.pinned ? 'forward' : 'back'); + } else { + $hint.innerText = ''; + $hintAction.removeAttribute('data-action'); + $hintAction.removeAttribute('title'); + $hintAction.setAttribute('aria-hidden', 'true'); + $hintAction.classList.toggle('is-hidden', true); + } } renderPin(state: CommitState) { diff --git a/src/webviews/commitDetails/commitDetailsWebview.ts b/src/webviews/commitDetails/commitDetailsWebview.ts index 048ce62..ed4aa2b 100644 --- a/src/webviews/commitDetails/commitDetailsWebview.ts +++ b/src/webviews/commitDetails/commitDetailsWebview.ts @@ -177,14 +177,20 @@ export class CommitDetailsWebviewProvider implements WebviewProvider> { @@ -283,6 +289,8 @@ export class CommitDetailsWebviewProvider implements WebviewProvider