a newly installed icon kept landing first, indexOf gives -1
This commit is contained in:
1 parent
219491ec2b
commit
9b8b56c5e4
1 file changed
+8
-3
@@ -13,9 +13,14 @@ module.exports = class RibbonOrderLock extends Plugin {
|
||||
const ribbon = this.app.workspace.leftRibbon;
|
||||
const order = this.settings.order;
|
||||
|
||||
const sorted = [...ribbon.items].sort(
|
||||
(a, b) => order.indexOf(a.id) - order.indexOf(b.id)
|
||||
);
|
||||
const sorted = [...ribbon.items].sort((a, b) => {
|
||||
const ia = order.indexOf(a.id);
|
||||
const ib = order.indexOf(b.id);
|
||||
if (ia === -1 && ib === -1) return 0;
|
||||
if (ia === -1) return 1;
|
||||
if (ib === -1) return -1;
|
||||
return ia - ib;
|
||||
});
|
||||
|
||||
ribbon.items.length = 0;
|
||||
ribbon.items.push(...sorted);
|
||||
|
||||
Reference in new issue
Block a user