From ffcaf31b159d74dc4bc18eefd1c9ebf37f6be652 Mon Sep 17 00:00:00 2001 From: Keith Daulton Date: Tue, 8 Nov 2022 13:58:27 -0500 Subject: [PATCH] Fixes ascending squash indicators in rebase editor --- src/webviews/apps/rebase/rebase.ts | 45 +++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/src/webviews/apps/rebase/rebase.ts b/src/webviews/apps/rebase/rebase.ts index 427a5b7..067d036 100644 --- a/src/webviews/apps/rebase/rebase.ts +++ b/src/webviews/apps/rebase/rebase.ts @@ -387,31 +387,26 @@ class RebaseEditor extends App { let tabIndex = 0; const $entries = document.createDocumentFragment(); - function appendEntries(this: RebaseEditor) { - const entries = state.ascending ? state.entries.slice().reverse() : state.entries; - let $el: HTMLLIElement; - for (const entry of entries) { - squashToHere = false; - if (entry.action === 'squash' || entry.action === 'fixup') { - squashing = true; - } else if (squashing) { - if (entry.action !== 'drop') { - squashToHere = true; - squashing = false; - } + for (const entry of state.entries) { + squashToHere = false; + if (entry.action === 'squash' || entry.action === 'fixup') { + squashing = true; + } else if (squashing) { + if (entry.action !== 'drop') { + squashToHere = true; + squashing = false; } + } - [$el, tabIndex] = this.createEntry(entry, state, ++tabIndex, squashToHere); + [$el, tabIndex] = this.createEntry(entry, state, ++tabIndex, squashToHere); - $entries.appendChild($el); + if (state.ascending) { + $entries.prepend($el); + } else { + $entries.append($el); } } - if (!state.ascending) { - $container.classList.remove('entries--ascending'); - appendEntries.call(this); - } - if (state.onto != null) { const commit = state.onto.commit; if (commit != null) { @@ -426,16 +421,16 @@ class RebaseEditor extends App { ++tabIndex, false, ); - $entries.appendChild($el); + if (state.ascending) { + $entries.prepend($el); + } else { + $entries.appendChild($el); + } $container.classList.add('entries--base'); } } - if (state.ascending) { - $container.classList.add('entries--ascending'); - appendEntries.call(this); - } - + $container.classList.toggle('entries--ascending', state.ascending); const $checkbox = document.getElementById('ordering'); if ($checkbox != null) { ($checkbox as HTMLInputElement).checked = state.ascending;