diff --git a/TODO.md b/TODO.md index 98bb2f6..70f64ad 100644 --- a/TODO.md +++ b/TODO.md @@ -7127,3 +7127,48 @@ completion should offer `tb.`'s hierarchical members, answering `None` when the index has no unit of that name. `docs/features/top-rooted-paths`. - [ ] owner/lead decision; if yes, `completion/member.rs` + tests + +## 66. Format Selection that fits where it stands (planned 2026-11-09, owner's order) + +Owner's report: *Format Selection* "fails more than half of the time". The +usual selection is one whole `always` block or one whole `case` statement, +often nested inside blocks the selection does not cover. Reproduced on trunk +(`lucisv --lines`, the engine `textDocument/rangeFormatting` shares): selecting +a `case` re-lays the whole `always` around it; the block is re-indented to the +formatter's own depth × width, so in a file indented any other way it no +longer lines up with its neighbours; a selection inside `generate` re-lays the +whole region; and a file with a parse error anywhere is refused outright. +Owner's rule: do not worry about the parent — the selected block keeps the +indentation level it starts at, and stays functionally the same. + +### 66.1 VS Code language configuration (lead, done 2026-11-09) + +- [x] `editors/vscode/language-configuration.json` (comment tokens, brackets, + auto-closing and surrounding pairs) wired to both language ids in + `editors/vscode/package.json` — Toggle Line/Block Comment (Ctrl+/) works + without another Verilog extension installed. + +### 66.2 Selection formatting (one lane: dev, then QA) + +Feature README: `docs/features/selection-formatting/README.md`. Files: +`crates/vlog_formatter/src/selection.rs` (+ a `selection/` split if it nears +600 lines), `crates/vlog_formatter/src/{lib.rs,printer.rs,format/mod.rs}`, +`crates/vlog_formatter/tests/selection.rs`, `crates/lucisv_server/src/format.rs`, +`crates/lucisv_server/src/server/tests/formatting.rs`, +`crates/lucisv_server/tests/e2e.rs`. `verify.rs`, `range.rs`, `fence.rs`, the +parser and the CLI's `--lines` are not touched. + +- [x] `format_selection`: the smallest run of sibling items/statements the + selected lines cover, laid out alone at the indentation it was written + at, spliced into otherwise untouched bytes. +- [x] Verified whole-file (`verify_equivalence`, unchanged) and converged by + replaying the located target, not the line numbers. +- [x] Fences outrank the selection; a module/package-level target defers to + `format_range` (header/footer splitting). +- [x] A file that does not parse: the target is located in the tolerant tree + and refused when a diagnostic falls inside it. +- [x] `textDocument/rangeFormatting` / `rangesFormatting` call it. +- [x] Tests: the owner's shapes (whole `always`, whole `case`, inside + `generate`, inside a function), off-grid and tab indentation, partial + selections, comments, fences, broken files, masked-corruption attacks on + the splice. diff --git a/editors/vscode/language-configuration.json b/editors/vscode/language-configuration.json new file mode 100644 index 0000000..233b4cb --- /dev/null +++ b/editors/vscode/language-configuration.json @@ -0,0 +1,24 @@ +{ + "comments": { + "lineComment": "//", + "blockComment": ["/*", "*/"] + }, + "brackets": [ + ["(", ")"], + ["[", "]"], + ["{", "}"] + ], + "autoClosingPairs": [ + { "open": "(", "close": ")" }, + { "open": "[", "close": "]" }, + { "open": "{", "close": "}" }, + { "open": "\"", "close": "\"", "notIn": ["string", "comment"] }, + { "open": "/*", "close": " */", "notIn": ["string"] } + ], + "surroundingPairs": [ + ["(", ")"], + ["[", "]"], + ["{", "}"], + ["\"", "\""] + ] +} diff --git a/editors/vscode/package.json b/editors/vscode/package.json index c726426..4f3f5ab 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -208,7 +208,8 @@ "extensions": [ ".v", ".vh" - ] + ], + "configuration": "./language-configuration.json" }, { "id": "systemverilog", @@ -219,7 +220,8 @@ "extensions": [ ".sv", ".svh" - ] + ], + "configuration": "./language-configuration.json" } ], "grammars": [