Skip to content

editor: /table focus, cell inline shortcuts, vim visual-mode snap - #522

Open
junereycasuga wants to merge 4 commits into
ZenNotes:mainfrom
junereycasuga:fix/table-interactions
Open

editor: /table focus, cell inline shortcuts, vim visual-mode snap#522
junereycasuga wants to merge 4 commits into
ZenNotes:mainfrom
junereycasuga:fix/table-interactions

Conversation

@junereycasuga

@junereycasuga junereycasuga commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Three table-editor improvements, all driven by the same friction: tables are atomic block widgets, so the normal CodeMirror text-editing affordances don't reach them.

1. Inline formatting shortcuts in cells

Cmd-B / Cmd-I / Cmd-E now wrap (or unwrap) the selection in bold, italic, code, directly inside a table cell. Toggle logic handles markers on either edge of the selection and supports word-run expansion when nothing is selected.

2. /table focuses the first header cell

Inserting a table via /table now drops you straight into the first header cell so you can start typing without an extra click. A bounded rAF retry (~200 ms) handles the parse lag between insertion and widget creation.

3. Vim visual-mode snap across tables

In vim visual mode, j/k toward a table used to drop the selection head inside the atomic interior — a partial delete there corrupts the markdown. Now the head snaps to the table's far edge in one motion, so d removes the whole table cleanly. A ViewPlugin toggles .is-selected on the covered widget (CM draws no selection background over block widgets) so the snap is actually visible.

Bug fix: leaked context-menu keydown listener

While testing, found that the table context menu's deferred setTimeout listener registration could fire after teardown already ran, permanently leaking a capture-phase keydown listener on window that swallowed arrow keys. Fixed with a tornDown guard.

Test plan

  • 1053 tests pass (56 in cm-table.test.ts), typecheck clean
  • Manual: type in a cell, select text, press Cmd-B — wraps/unwraps bold
  • Manual: /table — cursor lands in first header cell
  • Manual: vim visual mode, v then j over a table — whole table highlights, d deletes it

adibhanna added a commit that referenced this pull request Aug 3, 2026
CI has been red on Windows since #522's database fix landed, and only on
Windows: macOS, Linux x64 and Linux arm all pass the same test. It fails in
`TestReadNoteStatusesDistinguishMissingFromBroken`, which asks the server to
read `inbox/Db.base`, a database folder, and expects the 400 that says "that is
a directory, not a file". Windows answered 500.

The classification was made from the errno the read returned. `writeError`
tested for `EISDIR`, which is what Unix gives you for reading a directory.
Windows gives `ERROR_INVALID_FUNCTION` instead, printed in the CI log as
"Incorrect function", so the test missed and the request fell through to the
"something is broken here" branch. The server was not broken on either
platform; the same request simply got two different answers.

`ReadNote` already stats the path before reading it, so the answer is known one
line earlier and does not need to be inferred from a platform's error code. It
now returns a `vault.ErrIsDirectory` sentinel from that stat, the same shape as
the `vault.ErrPathEscape` the handler already maps, and `writeError` maps it to
400. The `EISDIR` test stays underneath it as a fallback for read paths that
have not been classified, where it is still correct on the platforms that
produce it.

The end-to-end test that caught this only fails on Windows, which is a poor
place to keep the guarantee, so the classification is pinned in the vault
package too: a directory is `ErrIsDirectory`, a real note still reads, and a
missing file inside that directory is still `os.ErrNotExist` rather than being
swallowed by the new branch. That test means the same thing on every runner.

Unrelated to the task work on this branch; it was inherited red.

How to test locally: `cd apps/server && go test ./...`. The new
`TestReadNoteRejectsADirectoryOnEveryPlatform` fails before this change on any
platform, because ReadNote returned the raw platform error rather than the
sentinel. The Windows half of the fix cannot be reproduced on macOS, which is
the reason it is no longer decided by an errno at all.
@junereycasuga
junereycasuga force-pushed the fix/table-interactions branch from e035e3f to dd0a06a Compare August 7, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant