I think the latest 312 release fixes most of these.
Crashes you hit
- “JSContext not available” from
performCommand in tests. When bike-ext test ran, Bike loaded a second copy of your extension, and the installed copy’s commands stayed registered. performCommand could call the stale copy, whose script context had gone away, and that was a hard crash. The test runner now unloads the replaced copy, and a missing context now throws a JS error instead of crashing Bike. You should be able to drop the context['vim'].perform test hook and call bike.commands.performCommand directly.
row.text = AttributedString.fromMarkdown(...) crashing. The crash happened when the assigned text was already attached to a row: another row’s text, or the same fromMarkdown value assigned to a second row. The setter now copies the value, so row.text = … is safe however you use it.
bike-ext test
- After a crash, the next test run no longer stalls behind the “reopen windows?” dialog.
console.log output from tests and extensions now prints in the terminal during test runs.
- Editor readiness: I ran your suite on my current build with your three
await tick() calls removed, and all 61 tests passed. So that workaround shouldn’t be needed anymore.
bike-ext submit now validates against the registry’s schema correctly, so you won’t have to add the entry by hand next time.
Copying branches
Passing rows to new Outline(...) or insertRows(...) now keeps their nesting when a row’s parent is also in the list. That makes row.descendantsWithSelf a branch copy, and your level-by-level copyRows becomes:
new Outline(cover.flatMap((row) => row.descendantsWithSelf))
This is still a bit odd, but makes copy branch possible without your own walk.
Multiple windows
state.ts keys visual mode and the mode indicator by editor.outline.root.id, but that id is 0 for every outline. With two windows open, visual mode carries over when you switch windows, and the second window can miss its -- INSERT -- / -- VISUAL -- label. There’s a new editor.id for this. Each window pane gets a unique id that stays the same while it’s open, so key your per-editor state by editor.id instead.
Key handlers
The bigger addition is a way to see raw key presses, so modal extensions don’t have to squeeze vim into fixed key sequences:
bike.keybindings.addKeyHandler({
keymap: 'block-mode', // or 'text-mode'
handle({ key, editor, selection }) {
// key is spelled like keybindings: 'j', 'shift-g', 'control-r', 'escape'
return false // return true to consume the key
},
})
Handlers get first refusal on every key: they run before the keymap’s keybindings and before menu shortcuts. Each press reaches a handler once. They’re skipped during IME composition and while a keybinding sequence is part-typed.
With this you can parse vim input yourself, the way CodeMirror’s vim mode does. That makes counts in the middle of a command (d3j), registers, . repeat and insert-mode keys like ctrl-w possible. It would also replace the ten vim:.count-N commands and the global pending count.
Thanks for all the feedback.