V2.2.1 [Bug] 1 space-lua block permits only 1 command.define, multiple will fail

see github issue:

after updated to v2.2.1

found missing ctrl+2~6 from [space-lua] Toggle / Rotate Header Level h1-h6-On/Off - #4 by Mr.Red

another example is:

I am using 2.2.1, and I can’t confirm this. If I understand your issue correctly is that if you define multiple /slash or normal commands using for clause, it doesn’t register all of them but the first one? Is that correct understanding? For me Ctrl-1 → Ctrl-6 still works in 2.2.1
And also the custom admonitions which use the same principle to define slash commands work as well. So maybe it’s a conflict with one of your installed plugins or maybe it’s a conflicting space-lua you’ve added.

Exactly. I am now trying to locate the reason behind :melting_face:

No problem now.

Though not knowing what was happening…

github issue is closed.

1 Like

I digged out the source:

applying

-- priority: -1
event.listen {
  name = 'hooks:renderTopWidgets',
  run = function(e)
    if not editor.getUiOption("darkMode") then
      editor.setUiOption("darkMode", true)
    end
  end
}

and Client: Wipe + Reindex will cause this problem.

while replaced by

-- priority: -1
event.listen {
  name = "hooks:renderTopWidgets",
  run = function(e)
    if not clientStore.get("darkMode") then
      clientStore.set("darkMode", true)
      editor.reloadUI()
    end
  end
}

there’ll be no problem then.

Seemingly unrelated huh?.. but it just happened…

the whole story origins from that I don’t what the flash caused by editor.reloadUI()… then I came up with the editor.setUiOption("darkMode", true), then here comes the problem…

emm… the (root) reason should be (shifted to) priority = 0 in command.define and .update I suppose -_-||

after I update all priority = 0 to priority = 1,

below code (that I thought was trouble-making)

-- priority: -1
event.listen {
  name = 'hooks:renderTopWidgets',
  run = function(e)
    if not editor.getUiOption("darkMode") then
      editor.setUiOption("darkMode", true)
    end
  end
}

now works with ctrl+2~6 in [space-lua] Toggle / Rotate Header Level h1-h6-On/Off - #4 by Mr.Red.

I forget to check console (first)…



along the way, found something interesting:

  1. a virtual page has no bottom widget, but SB is trying to render that

  1. SB is trying to create a real page with the same name of the virtual page

1 Like

usually when i discover things/issues/bugs, i just start a brand new stock space, to see if the issues is also present there, and if the issues does not show up in the vanilla space, then the issue is definitely on my part with one of my installed plugs, or my space-lua exeperiments all over my place. i also have three different runnings spaces which i switch for different tasks: one for playing and testing, another for work and another for my personal notes and tested and working scripts only. if an issue is on all three of the spaces, then it is usually a bug, but if i can only track it on one of my instances, then i digg deaper to find out what could the reason behind it be.

1 Like

that’s mind-blowing… 3 instances… definitely SB expert way of inspecting flaws…

I’ve learnt that now. (hope no more fake bug report from +2 instances on :slight_smile:

1 Like