Files
lucisv/docs/features/completion-ux/README.md
T
lucioandClaude Mythos 5.2 c1076f9405 TODO §68.1: begin+Enter writes the end, clock+reset templates, this file's names first, keyword ghosts, port items that write .name()
Server (lucisv_server only): on_type/auto_end.rs — the newline answer
adds the owed end at the owning statement's indentation (lucisv.autoEnd);
always_ff @( / always @( ghosts and popup templates lead with posedge clk
or negedge rst_n; completion tiers put names declared and used in this
buffer ahead of the index, templates and keywords (completion/buffer.rs);
inline/keywords.rs ghosts the rest of a keyword and follows the popup's
selected entry (lucisv.inlineKeywords); connection items keep connected
ports as a second group marked 'connected' and insert name($1), pre-filled
with a same-named signal (completion/connection.rs).
Extension: typing.js sends the newline on-type request itself when
editor.formatOnType is off and restores the cursor; the inline-completion
context is converted to LSP shapes.
Dev + QA (Opus 5.5) + one fix round; unit 1823, e2e 102, node 9 files,
smoke OK. Not yet seen in a running VS Code.
docs/features/completion-ux.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
2026-11-17 14:39:32 -08:00

449 lines
28 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# completion-ux
## Goal
Completion that keeps up with typing (TODO §68.1, owner's order 2026-11-17).
Five changes to the editing loop the VS Code extension drives, all served by
`lucisv-server` so other LSP clients get them too:
1. **`begin` + Enter writes the `end`.** The newline on-type answer, when the
line above ends in `begin` / `begin : label` and the block still owes an
`end`, also writes `end` on the line after the new one, at the owning
statement's indentation; the cursor stays on the indented body line. The
extension sends that request itself when `editor.formatOnType` is off.
2. **Clock and reset in the `always` templates.** `always_ff @(` and
`always @(` ghost `posedge ${1:clk} or negedge ${2:rst_n}) begin … end`
first; the clock-only form stays as the second choice, in the ghost and in
the popup.
3. **Current-file names rank first** in the popup: what this buffer declares
(any scope), then the words it uses, ahead of other files' names, the
templates and the keywords.
4. **Keyword ghosts.** A typed proper prefix of a keyword shows the rest as
grey inline text, following the popup's selected item while the popup is
open.
5. **Port items.** After the `.` of a connection, unconnected ports first,
connected ones after them marked `connected`; accepting one writes
`.name($1)` with the cursor inside the parentheses, pre-filled with a
same-named signal when the instantiating scope has one.
## Assumptions
- **Auto-`end` — which `begin` owes an `end`.** `pairs::analyze` is a stack
matcher, so a `begin` typed inside a balanced block steals that block's
`end` and the *outer* `begin` comes out unmatched. The rule
(`on_type/auto_end.rs::owes_an_end`): no `end` if this `begin` is matched by
an `end` that is first on its line at exactly the indentation the answer
would write; otherwise an `end` iff any `begin` at or before this one is in
`unmatched_open`. Fix round: the `begin` also counts as closed when its
matched `end` starts its line at the `begin`'s **own** line's indentation
(GNU layout, `begin` on its own line), and an unmatched `begin` inside a
`` `ifdef ``/`` `ifndef `` region that has an `` `else ``/`` `elsif ``
arms nothing. Consequence: an unrelated unclosed `begin` earlier in the
file still arms it (accepted heuristic, lead's ruling); a hand-mis-indented
`end` belonging to an outer block at either column disarms it.
- **Auto-`end` and `` `ifdef `` branches (QA finding 1).** Two branches that
each open the same block (`` `ifdef A always … begin `else always … begin
`endif `` and one shared `end`) are complete code that the stack matcher
reads as one unmatched `begin`. What is right after the *first* branch's
`begin` is **no `end`**: the block's `end` is the shared one after the
`` `endif ``, and a second would break the other branch. The cheap rule —
an unmatched `begin` inside a branched conditional region never arms the
answer — gets that right. Known limit it buys: a genuinely new `begin`
typed inside such a region whose only unmatched `begin` is itself gets no
`end` (the plain indent answer instead). The region scan is by directive
word over the token stream; a region never closed runs to end of buffer.
- **Auto-`end` — the owner line.** Read backwards from the `begin` over a
parenthesised header, `@`/`#` and its operand, one header keyword (`if`,
`for`, `foreach`, `while`, `repeat`, `forever`, the `always` family,
`initial`, `final`) and the qualifiers in front of it (`else`, `unique`,
`unique0`, `priority`). Anything else ends the walk. The `end` takes that
line's leading whitespace *as written* (tabs stay tabs). An unmatched `)`
leaves the `begin`'s own line as the answer.
- **Auto-`end` — the body line.** The nesting model's level (spaces, as the
plain newline answer) when it lies deeper than the `end`; else the `end`'s
indent plus one `lucisv.indent`-width step; a tab-indented `end` gets one
more tab.
- **Auto-`end` — only on a blank new line.** Enter pressed mid-line carries
text down, and that line gets the plain indent answer only. The previous
line must *end* in `begin` / `begin : label`; comments are trivia and do not
count. Only `begin` — not `fork`, `case`, `module`.
- **Auto-`end` edit shape.** Two edits: the new line's leading whitespace
(omitted when already right) and an insertion of `<indent>end<eol>` at
column 0 of the line *after* the new one, so no edit touches the cursor
position. When the new line is the file's last line there is nowhere else to
put it: one edit replaces the new line with `body<eol><indent>end`. The
line ending is the one just typed (`\r\n` files stay `\r\n`).
- **Extension path.** `editors/vscode/typing.js` acts on an
`onDidChangeTextDocument` event with exactly one content change, no
`reason` (undo/redo are skipped), `rangeLength` 0, text matching
`^\r?\n[ \t]*$`, a line before it ending in `begin`/`begin : label`
(a `//` comment stripped), `editor.formatOnType` **not** on for the
document (language overrides honoured via `getConfiguration('editor',
document)`), and `lucisv.autoEnd` not `false`. The request goes out on the
next tick (`setTimeout 0`) so the language client's own `didChange` for the
same event is sent first. The answer is applied only if the document
version is unchanged and the answer writes an `end` (an indent-only answer
is formatting the user never turned on). Applied with `editor.edit(…,
{ undoStopBefore: false, undoStopAfter: true })`, then the cursor is put at
the end of the new line.
- **Undo.** The edit has no undo stop before it, so VS Code should fold it
into the Enter's own undo step: one `Ctrl+Z` removes the `end`, the indent
and the newline together. Not verified in a running VS Code (see QA).
- **Templates.** Popup template `sortText` is now `5` + three-digit registry
rank + label, so templates reached by the same prefix show in registry order;
the with-reset `always_ff` / Verilog `always @(posedge … or negedge …)` were
moved ahead of the clock-only ones. Labels unchanged.
- **Ranking — the final tier table** (`completion/mod.rs`; the first
character of every `sortText`, a label follows, so the order is total):
| digit | tier | source |
|---|---|---|
| `0` | module names (item position) / members (exclusive answer) | index / site |
| `1` | visible at the cursor (scope chain); in a connection list: already-connected ports | `Semantics` |
| `2` | declared anywhere in this buffer | `Semantics::symbols()` |
| `3` | identifiers used in this buffer (not the token under the cursor) | token stream |
| `4` | what the project declares (units, members, `` `define ``s) | index |
| `5` | templates (`5` + rank + label) | `templates.rs` |
| `6` | keywords | `vlog_parser::KEYWORDS` |
| `7` | project words | candidate tables |
Dedup by label is unchanged: the first (best) tier wins. VS Code sorts by
its own fuzzy score first and uses `sortText` among equal scores, so the
tier order decides between equally good matches only.
- **Ranking — the typed word itself.** The buffer-word tier skips the token
starting at the cursor's word, so a half-typed `c` is no longer offered
back as `c` (it used to be, by the old word tier). A saved copy of the same
file still contributes it through the project-word table.
- **Keyword ghosts.** `inline/keywords.rs`. Asked only when no template
trigger answered and the rest of the line is blank (the existing ghost rule).
The word: the token ending exactly at the cursor, `Ident` or `Keyword`,
ASCII identifier characters starting with a letter, length ≥ 2, not after
`.`/`::`, and not exactly a name this buffer declares (fix round: `in`,
`re`, `out` as signals stay quiet; an undeclared word ghosts in any
position, expressions included). A word that is already a keyword only
extends across `_`
(`always` → `always_ff`; `end`, `for`, `case` get nothing — a ghost after a
finished keyword is noise a stray Tab accepts) — unless the popup has
that keyword selected: an explicit selection wins (`end` with `endmodule`
selected ghosts `endmodule`). Choice: the popup's
`selectedCompletionInfo.text` when present and its range is exactly the
typed word (start of the word to the cursor; any other range is read as no
selection and never echoed back) — ghost exactly it, over that range, if
it is a reserved word of the dialect extending the word, otherwise no
ghost, since VS Code would hide a disagreeing one; else the first of a fixed priority
list (`PRIORITY`); else shortest-then-alphabetical over `KEYWORDS`. A `.v`
buffer is limited to the IEEE 1364-2005 reserved words. Item shape: with
no selection, empty range at the cursor and the suffix as a snippet value
(the existing ghosts' shape); with a selection, the selection's range and
the whole keyword (LSP 3.18: "must extend the text of the selected item and
use the same range").
- **Extension bridge (corrected in the fix round, QA finding 2).**
`vscode-languageclient` 9 passes VS Code's `selectedCompletionInfo` through
unconverted, so a `vscode.Range` goes out in its `toJSON` array shape and
the trigger kind as VS Code's 0/1 rather than LSP's 1/2. **Nothing was
broken by this**: serde decodes the server's `Range` struct from a
two-element sequence and the trigger kind is an `i32` newtype, so the
request decoded and the template ghosts kept working (pinned by
`qa_an_array_shaped_range_and_a_zero_trigger_kind_still_decode`). The
`middleware.provideInlineCompletionItems` re-spelling both
(`typing.protocolInlineContext`) is correctness hygiene: the spec's
spelling on the wire, and correct trigger kinds for any server that reads
them.
- **Port items.** `completion/connection.rs`. Applies to both connection
lists — ports after `inst (` and parameters after `#(`. Connected entries
are those `connected_names` finds (the entry being re-typed excluded); they
get `sortText` `1<name>` and `labelDetails.description = "connected"`.
Within each group the order is the match order, as before (`sortText` is
alphabetical by name within a digit, also as before). Snippet
`name(${1:fill})` / `name(${1})` only for a client with snippet support, no
`(` after the identifier run being replaced (same line, spaces/tabs
skipped), and a plain-identifier name. Pre-fill when the scope chain at the
cursor binds a `Net`/`Var`/`Port` (ports) or `Param`/`LocalParam`
(parameters) of the same name. **An auto-closed `)` is not handled**: the
popup is reached after a `.`, where no paren has been typed yet; if the user
had typed `.cl(` and gone back, the `(` check already gives the bare name.
- **Known limits accepted by the lead (QA notes 6–11).**
- *LIMIT starvation moved* (6): with ≥ 512 names in this file matching a
one-letter prefix (a synthetic 600-`logic aN;` buffer), templates and
keywords fall out of the one-letter answer; `isIncomplete` is true, so
the second letter re-asks and gets them. Largest real case seen: 220
items (`r` in `ibex_core.sv`).
- *Token under the cursor* (7): tier 3 skips it even mid-word, so a word
this file uses exactly once and declares nowhere drops out while the
cursor is inside it.
- *Body indent inside `fork`* (8): the body line's indent is the existing
nesting model's answer (identical to the plain newline answer), so
`initial fork\n begin` + Enter gives an 8-space body over a 4-space
`end`.
- *Pre-fill* (9) accepts a same-named signal declared after the instance —
the scope chain binds it either way.
- *Last line under formatOnType* (11): there the answer is one edit whose
range contains the cursor, so VS Code probably leaves the cursor after
the `end`; the extension path puts it back itself.
## Handshakes
- **Consumes** `pairs::analyze` (unchanged), `on_type::level_at` (unchanged,
called from the child module), `Semantics::symbols()` / `scopes()`,
`signature::enclosing_list`, `candidates::{Query, rank_cmp}`.
- **Changed, crate-internal:** `on_type::on_type_formatting` takes a fifth
argument `auto_end: bool` (one caller, `server/formatting.rs`). The inline
entry point is now `inline::inline_completions_in_context(ws, uri,
position, selected)`; the old three-argument `inline_completions` survives
as a `#[cfg(test)]` wrapper so `instantiate.rs`'s test (outside this lane's
files) compiles unchanged. `completion::member_answer` takes `snippets`.
`tiers::visible_symbols` is `pub(super)`. Fix round: `on_type::begin_owes_an_end(doc, begin_index)`
(`pub(crate)`, re-exported from `on_type/auto_end.rs`) is what
`inline.rs`'s `begin` ghost gate now asks.
- **Changed, protocol-visible:** popup `sortText` digits (table above) — any
client or test that pinned `2`/`3`/`4`/`5` for index/template/keyword/word
sees `4`/`5`/`6`/`7`; template `sortText` gains a rank; connection items
gain `labelDetails` and snippet `textEdit`s. Settings `lucisv.autoEnd`,
`lucisv.inlineKeywords` (both boolean, default true, absent = on).
- **Outside the file list, flagged:** `editors/vscode/.vscodeignore` gained
`typing_test.js` (and `typing.js` in its comment), as the lane brief's
pointer to the restart.js/.vscodeignore pattern implied.
- No request to the parser, semantic or formatter crates.
## Status / TODO
- [x] auto-`end` on Enter: server (`on_type/auto_end.rs`, setting, wire) and
extension (`typing.js`, `extension.js`, `package.json`)
- [x] clock+reset templates (ghost + popup order)
- [x] current-file ranking (`completion/buffer.rs`, tier table)
- [x] keyword ghosts (`inline/keywords.rs`, setting, extension bridge fix)
- [x] port items (`completion/connection.rs`, `member.rs`)
- [x] unit, e2e and node tests; VS Code README; TODO §68.1 ticked
- [ ] confirmed in a running VS Code (see QA log — nobody has seen it yet)
## Work log
- **2026-11-17 (dev, Opus 5.5).** All five deliverables.
- `on_type/auto_end.rs` (new child module of `on_type.rs`): the begin-newline
answer; `on_type_formatting` tries it first when `auto_end` and falls back
to the unchanged indent answer. Old on-type tests pass `false`, so their
pins are untouched; 15 new tests (steal case, balanced, inner-closed with
outer missing, label + comment, wrapped header, `end else begin`, case
item, tabs, CRLF, last line, setting off, non-begin lines, text carried
down, begin two lines up).
- `templates.rs`/`inline.rs`/`completion`: with-reset first; template
`sortText` by registry rank (the label alone sorted `always @(*)` first).
- `completion/buffer.rs` (new): tiers 2 and 3; `word_tier` reads only the
table now. Decision: the typed token itself is not offered back (golden
`the_short_answers_are_what_they_always_were` updated, reasoned in place).
- `inline/keywords.rs` (new): keyword ghosts. Deviation from the brief's
"proper prefix of a keyword": a finished keyword only extends across `_`.
Found and fixed the `selectedCompletionInfo`/trigger-kind serialization
gap in the client bridge.
- `completion/connection.rs` (new) + `member.rs`: connected ports kept and
marked, snippet entries, pre-fill; parameters treated the same way.
- Extension: `typing.js` + `typing_test.js` (35 checks), wired in
`extension.js` (middleware + change listener), two settings in
`package.json`, README feature table and settings.
- `smoke.js` not changed: no existing probe's expectation moved (smoke run
recorded in the report).
- **2026-11-17 — fix round 2026-11-17 (dev, Opus 5.5)**, after QA and the
lead's rulings:
1. `owes_an_end`: closed also when the matched `end` sits at the `begin`'s
own line's indentation; an unmatched `begin` in a branched `` `ifdef ``
region arms nothing (`branched_regions`). Tests:
`a_gnu_style_begin_already_closed_under_itself_gets_no_end`,
`qa_ifdef_branches_sharing_one_end_get_no_second_end` (both QA repro
cases), `an_ifdef_with_no_else_still_arms_the_answer`.
2. "Extension bridge" assumption reworded: nothing was broken.
3. Keyword ghost: none for a word that is exactly a name the buffer
declares (`Semantics::symbols()` scan).
4. An explicit popup selection skips the finished-keyword rule
(`reserved_extension`).
5. A selection whose range is not exactly the typed word is read as absent.
6. `typing.js` strips trailing `/* … */` comments too (4 new checks).
7. The inline `begin` ghost gate asks `on_type::begin_owes_an_end` (new
`pub(crate)` re-export), so the stealing case ghosts its `end`; test
`a_begin_typed_inside_a_balanced_block_still_offers_its_end`.
Known limits 6–11 written into Assumptions.
## QA log
- **2026-11-17 (QA, Opus 5.5).** Verdict: **pass with findings** — no
MUST-FIX. Two SHOULD-FIX, the rest NOTEs for the lead.
**Gates (re-run by QA).** `cargo fmt --check` clean. Guarded `cargo clippy
-p lucisv_server --all-targets`: 0 warnings. Guarded `cargo test -p
lucisv_server`: 1813 unit passed / 36 ignored, e2e 102 / 2 ignored, grammar
3, opentitan_references 0 / 2 ignored (guard exit 0); after the QA tests
below, 1816 unit. `node --test editors/vscode/*_test.js`: 9 files pass
(typing_test 35 checks, 48 with QA's). Release build +
`node editors/vscode/smoke.js target/release/lucisv-server`: OK, 67
messages.
**Scope.** Diff touches only the §68.1 file list plus the flagged
`.vscodeignore` line; no parser/formatter/linter/semantic change.
(`gemini_review.md` at the root is untracked but dated 2026-10-19 — not
this lane's.) Production lines (before `mod tests`): `auto_end.rs` 184,
`keywords.rs` 242 (125 of them the Verilog word table), `buffer.rs` 68,
`connection.rs` 55, `inline.rs` 331 (was 319), `on_type.rs` 361 (354),
`completion/mod.rs` 287 (245), `member.rs` 209 (187), `tiers.rs` 162 (186),
`settings.rs` 240 (234), `templates.rs` 326 — none near 600; no new
function over 80 lines. No `unwrap`/`expect`/`panic!` in added non-test
code; `auto_end.rs` indexes `tokens[...]` with indices bounded by
construction (`prev < first <= begin < len`).
**How.** A Python stdio LSP driver against the release binary, and the same
driver against a release build of `HEAD` (exported with `git archive`, own
target dir) for before/after; sabotage-free throwaway copy for the corpus
sweep. Scripts and outputs: the QA scratchpad `qaA/` (`autoend.py`,
`ghosts.py`, `ports.py`, `perf.py`, `labels.py`, `starve.py`).
**Auto-`end`.** 46 hand cases applied to the buffer and read: nested
stealing inside a balanced `always_comb`, case items, generate `if`/nested
`for … begin : g`, function/task/class method, `fork … join`, `begin :
label` (any spacing), `begin // c`, `begin /* c */`, `else begin`, `end
else begin`, wrapped `else if (b &&\n c) begin`, `@*`, `@(*)`, `#5 begin`,
`assert … else begin`, `unique if`, `blk: begin`, header on the line above
the `begin`, tabs, CRLF, last line with and without a final newline,
whitespace-only new line with the cursor mid-indent — all write the right
`end` at the right column. Declines (and **the declined answer is
byte-identical to `HEAD`'s indent answer** in every case): balanced block,
`begin` in a comment / string / escaped identifier / attribute, `` `define
`` line (with and without `\` continuation), `begin end` on one line, text
carried down, two blank lines, a buffer that does not lex. `autoEnd=false`
equals `HEAD` in all 46. Idempotence: applying each answer and asking again
at the same spot never writes a second `end`. **Corpus sweep** (860 files,
every one of 8 235 lines ending in `begin`, Enter simulated after it):
**0 spurious `end`s**; positive control (file truncated after its first
`begin`): 512/525 armed; 0 corpus files have a permanently unmatched
`begin`. Timing: < 1 ms per answer.
**Ghost/popup templates.** `always_ff @(` ghosts with-reset then clock-only;
`always @(` with-reset, clock-only, `*`; popup `alw` in `.sv`: `always_ff
with reset`, `always_ff @(posedge clk)`, `always_comb begin/end`; in `.v`:
with-reset, clock-only, `@(*)`. Snippet syntax well-formed, tab stops 1, 2
(mirrored `$2` in the popup body), 3/4, `$0`.
**Ranking.** Tier digits match the table; dedup by first push. Labels
offered at 68 positions in `ibex_core.sv` (mid-word and word-end): **none
lost** against `HEAD`. Timing per completion (20 requests, minus an empty
session; two runs each), HEAD → NEW: `picorv32.v` `a` 0.25/0.29 →
0.43/0.35 ms, `r` 0.36/0.33 → 0.50/0.58; `ibex_core.sv` `a` 0.09/0.22 →
0.27/0.33, `r` 0.65/0.63 → 0.71/0.74. Sub-millisecond either way.
**Keyword ghosts.** None in a line/block comment, an unterminated string,
after `.`/`::`/backtick, for `$dis`, or mid-word; `.v` gets `always` /
`localparam` (no `logic`); each setting off independently. Selection
present with a keyword → that keyword over its range; with a non-keyword →
nothing. **The extension bridge is real**: `vscode-languageclient` 9.0.1
`asInlineCompletionParams` passes `context` through
(`InlineCompletionContext.create(triggerKind, selectedCompletionInfo)`),
and `middleware.provideInlineCompletionItems(document, position, context,
token, next)` is the hook it calls.
**Port items.** Unconnected first, connected after with `connected`
(including a port connected *after* the cursor and a port connected twice);
`.name(${1})`, pre-filled only from a visible net/var/port (a same-named
`localparam` is not used for a port; a `clk` in a named block or another
module of the file is not used); `#(.` pre-fills from a `localparam`;
escaped port → bare name; `.*` present → fine; unknown module → empty;
`.cl|(x)` → bare; no snippet support → bare everywhere.
**Findings.**
1. **SHOULD-FIX — a second `end` in complete code when the file holds
another unmatched `begin` and this block's `end` is not at the owner's
column.** The accepted heuristic, but the GNU layout makes it reachable
in valid code: `` module m;\n`ifdef A\n always @(posedge clk) begin\n`else\n always @(posedge clk or negedge rst) begin\n`endif\n if (x)\n begin\n|\n y <= 1;\n end\n end\nendmodule `` → ` end` written under the `if`, so the file
now has one `end` too many. Same with the cursor after the *first*
`` `ifdef `` branch's `begin` (an `end` lands inside branch A). Any
mid-edit unmatched `begin` above has the same effect on a GNU-style
block below. Corpus exposure measured at 0 (no corpus file is
permanently unbalanced). Suggested: also treat the `begin` as closed
when its matched `end` starts its line at the `begin`'s own line
indentation. Lead to rule.
2. **SHOULD-FIX (docs) — the "Extension bridge" assumption overstates the
bug it fixes.** The server *does* decode VS Code's array-shaped range and
trigger kind 0 (serde reads a struct from a sequence); before the bridge
the request did not fail and the template ghosts did not die. The bridge
is still right (spec spelling, correct trigger kinds). Pinned by
`qa_an_array_shaped_range_and_a_zero_trigger_kind_still_decode`. The
README paragraph should say so.
3. NOTE — keyword ghosts with no popup open fire on declared names and in
expression position: `assign out = in` → `put`, `x = re` → `turn`
(`return` is ahead of `reg` in `PRIORITY`; `.sv` only), `x = ou` →
`tput`, `x = al` → `ways_ff`. With the popup open VS Code's selection
is normally the exact-match signal, which silences the ghost. Lead to
rule whether an exact declared name or a non-statement position should
suppress it.
4. NOTE — the finished-keyword rule also applies to an explicit popup
selection: typed `end` with `endmodule` selected → no ghost (spec says
the ghost follows the selected item). Preview only; the popup accepts
it anyway.
5. NOTE — a `selectedCompletionInfo` whose range is elsewhere is echoed
back as the item range (VS Code would drop it); one missing `text`
fails the whole request with -32602 (pre-existing decode behaviour).
6. NOTE — `LIMIT` starvation moved: with ≥ 512 names in *this file*
matching a one-letter prefix (synthetic: 600 `logic aN;` in another
module), templates and keywords fall out of the answer (`HEAD` kept
them; `isIncomplete` is true, so the second letter re-asks). Not seen on
real files (largest: 220 items for `r` in `ibex_core.sv`).
7. NOTE — the typed token itself is skipped by tier 3 even mid-word, so a
word the file uses exactly once and declares nowhere drops out while the
cursor is inside it (68-position check found no case in `ibex_core.sv`).
8. NOTE — `fork … join` body: `initial fork\n begin` + Enter gives an
8-space body over a 4-space `end`; the body indent is the nesting
model's (identical to `HEAD`'s plain answer), not the lane's.
9. NOTE — pre-fill accepts a signal declared *after* the instance
(`sub u (.);\n logic clk;` → `clk(${1:clk})`).
10. NOTE — `typing.js` strips `//` comments only: `begin /* c */` + Enter
gets an `end` with `editor.formatOnType` on (server answers) but not
with it off (extension never asks).
11. NOTE (unverifiable here) — the last-line answer is one edit whose
range contains the cursor; with `editor.formatOnType` on, VS Code will
likely leave the cursor after the `end`, not on the body line (the
extension path puts it back itself). Needs a running VS Code, as do:
the one-step undo, the extension's `didChange`-before-request ordering
(reading `vscode-languageclient` 9.0.1 it holds: the incremental
`didChange` is sent from microtasks before the `setTimeout(0)` task),
and the ghost following the popup.
**QA tests added.** `on_type/auto_end.rs`:
`qa_asking_again_after_the_answer_is_applied_adds_no_second_end` (9
armed shapes), `qa_a_declined_newline_is_exactly_the_plain_indent_answer`
(9 declining shapes, incl. `` `define ``, `` `ifdef `` both branches,
string, escaped `\begin`). `inline/keywords.rs`:
`qa_an_array_shaped_range_and_a_zero_trigger_kind_still_decode`.
`editors/vscode/typing_test.js`: `qaEdges` (13 checks: multi-cursor, redo,
no editor, refused edit, CRLF position, pastes, context without a range).
## Review
### 2026-11-17 — lead (after dev, QA, one fix round)
Accepted. QA found no corruption, crash or spec violation; both SHOULD-FIX
items and the rulings below went into the fix round, and the dev's gates
after it are green (unit 1 823, e2e 102, node 9 files, smoke OK).
Rulings recorded:
- **Auto-`end` is armed by any unclosed `begin` at or before this one**, not
by this `begin`'s own span (the stack matcher lets a new inner `begin`
steal the outer `end`). Closed means: matched by an `end` that starts its
line at the indentation the answer would write, or at the `begin`'s own
line's (GNU layout). A `begin` unclosed inside an `ifdef` region with an
`else`/`elsif` arms nothing — the shared `end` after `endif` is its `end`.
- **No keyword ghost for a word that is exactly a name this buffer
declares** (`in`, `re`, `out` as signals stay quiet). Anything else that
is a keyword prefix ghosts, in any position — the owner asked for
"always".
- **An explicit popup selection wins** over the "finished keyword only
extends across `_`" rule; a selection whose range is not the typed word
is ignored.
- Accepted limits (in Assumptions): LIMIT 512 can drop templates/keywords
in a 600-same-prefix buffer; the token under the cursor is not offered
back; port pre-fill accepts a later declaration; the last-line answer is
one edit that contains the cursor.
**Not verified by anyone:** every behaviour in a running VS Code — the
cursor after `begin` + Enter (formatOnType on and off), one-step undo, the
ghost following the popup selection, the dimmed `connected` detail. The
list is in the dev's report and the QA log; it is the owner's acceptance.