Repository navigation
feat(hover): CASE, OF and END cards list the CASE's branches - #857
Conversation
In a long CASE EVENT() or CASE FIELD() there was no quick way to see the branches or jump to one. The hover cards of a CASE, its OF / OROF / ELSE and its END now list the CASE's branches: one row per branch, its line number as a link, then the branch's source line with its comment. The OF and END cards put the CASE line first and mark the hovered branch. A nested CASE lists only its own branches; IF cards and a CASE without branches are unchanged. Rows come from Token.branches, which populateBranches() already fills, and each link has a title (Go to branch / Go to CASE / Go to END) a client can key on. Tests: new HoverProvider.CaseBranchList.test.ts, 13 tests, 11 of which fail without the source change (the other two guard unchanged cards). Server suite: 4557 passing, 3 pending. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
f500ef8 to
8379812
Compare
|
Thanks for this, it's a nice card. The review results:
The markdown escaping, the links (1-based, through One thing to change before we merge: Could you make these changes?
A small optional one: — Alice |
…r all Review follow-up. A generated CASE EVENT() can have hundreds of branches, so the branch list is now capped at 40 rows. The hovered branch is always kept, and a "...N more" row links to the first branch left out. A client that limits the list's height itself can announce capabilities.experimental.clarionCaseBranchListAll to get every branch. Each row's text is cut at 100 characters before the markdown escaping. The hovered row is now marked by branch index rather than line, so "OF 1 OROF 2" on one line marks only the hovered keyword. A backslash before a | in the source gets a zero-width space after it: marked counts the backslashes before a pipe and otherwise ends the cell there. Tests: 8 new in HoverProvider.CaseBranchList.test.ts (60-branch CASE, OF past the cap, END card, list-all client, same-line OROF, \|, long line); 7 fail without the change. Server suite: 4564 passing, 3 pending; one timing-sensitive SDI disk cache test timed out under full load and passes on its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The language server's CASE / OF / END cards are getting a cap (msarson/Clarion-Extension#857): at most 40 branches and a "...N more" row, unless the client announces capabilities.experimental.clarionCaseBranchListAll. This page limits the list's height and scrolls it itself, so LspClient now announces the flag next to clarionAttributeEditLinks and keeps getting the whole list. A server without the cap ignores the flag. Checked live against a 163-branch CASE: every branch is returned and no "...N more" row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the review. Pushed b524403 with the changes:
Two additions:
On the Server suite: 4564 passing, 3 pending. One SDI disk cache test ( |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
What this changes
The hover cards of a CASE, its OF / OROF / ELSE and its END list the CASE's branches: one row per branch, the line number as a link to it, then the branch's own source line, comment included. In a long
CASE EVENT()orCASE FIELD()the card becomes a quick way to see the branches and jump to one, without scrolling through the block.Hovering CASE:
Hovering OF
▸. The CASE line is the list's first row, in place of the separate code block and link to it, which keeps the card short.The line links are links to the same document, labelled with the line number only (no file name), each with a link title:
Go to branch,Go to CASE,Go to END. A client that wants to style the list can key on the title. VS Code shows the whole table in its hover, which scrolls as usual.How it works
The branches are already recorded:
DocumentStructure.populateBranches()puts every OF / OROF / ELSE of a CASE inToken.branches, with its line, and leaves out a nested CASE's own branches.HoverRouter.handleBlockOpener: a CASE with recorded branches getsbuildCaseBranchList(header + table) instead of the closed-by card.HoverRouter.caseBranchTable(caseToken, document, current?, withOpener?): the table rows fromcaseToken.branches;currentmarks the hovered branch,withOpenerputs the CASE line first. Used by the CASE card,handleBranchKeywordandbuildTerminatorHover.HoverRouter.tableCode: the source line as inline code in a table cell,|escaped and a longer backtick fence when the line holds a backtick.HoverFormatter.lineLink(uri, line0, title?): a[n](file:///…#Ln "title")link with the bare line number as its label.Open questions
Tests
HoverProvider.CaseBranchList.test.ts(new, 13 tests): the rows and their order, line-number links with titles and no file names, the hovered-branch marker on OF / OROF / ELSE, the CASE row on the branch and END cards, nested CASEs,|and backtick escaping, IF cards unchanged, a CASE without branches unchanged. With the source change removed, 11 of the 13 fail; the two that still pass are the unchanged-card guards. The full suite passes: 4557 passing, 3 pending.