Skip to content

Commit

Permalink
Fixes ascending squash indicators in rebase editor
Browse files Browse the repository at this point in the history
  • Loading branch information
d13 committed Nov 8, 2022
1 parent 0f13387 commit ffcaf31
Showing 1 changed file with 20 additions and 25 deletions.
45 changes: 20 additions & 25 deletions src/webviews/apps/rebase/rebase.ts
Expand Up @@ -387,31 +387,26 @@ class RebaseEditor extends App<State> {
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) {
Expand All @@ -426,16 +421,16 @@ class RebaseEditor extends App<State> {
++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;
Expand Down

0 comments on commit ffcaf31

Please sign in to comment.