Fix: cycle through editors
This commit is contained in:
parent
9250d5c624
commit
872f34f999
|
@ -201,35 +201,27 @@ function createSectionsEditor(style) {
|
|||
}
|
||||
|
||||
function nextEditor(cm, cycle = true) {
|
||||
if (!cycle) {
|
||||
for (const section of sections) {
|
||||
if (section.isRemoved()) {
|
||||
continue;
|
||||
}
|
||||
if (cm === section.cm) {
|
||||
if (!cycle && findLast(sections, s => !s.isRemoved()).cm === cm) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return nextPrevEditor(cm, 1);
|
||||
}
|
||||
|
||||
function prevEditor(cm, cycle = true) {
|
||||
if (!cycle) {
|
||||
for (let i = sections.length - 1; i >= 0; i--) {
|
||||
if (sections[i].isRemoved()) {
|
||||
continue;
|
||||
}
|
||||
if (cm === sections[i].cm) {
|
||||
if (!cycle && sections.find(s => !s.isRemoved()).cm === cm) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return nextPrevEditor(cm, -1);
|
||||
}
|
||||
|
||||
function findLast(arr, match) {
|
||||
for (let i = arr.length - 1; i >= 0; i--) {
|
||||
if (match(arr[i])) {
|
||||
return arr[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function nextPrevEditor(cm, direction) {
|
||||
const editors = getEditors();
|
||||
cm = editors[(editors.indexOf(cm) + direction + editors.length) % editors.length];
|
||||
|
|
Loading…
Reference in New Issue
Block a user