Skip to content

v2.0.2

@zensh zensh tagged this 26 Aug 08:22
Four defects, all in the paths that run while a command is half-typed β€” which
is most of the time an editor extension is doing anything. Release 2.0.1, which
also carries `@ldclabs/kip-lang` 2.0.2: that release stopped the formatter from
rewriting what a filter means, and this extension formats on save, so the fix
only reaches an editor through a new build.

**An unterminated string swallowed the document.** The TextMate rule ended only
at a closing quote, and a `begin`/`end` rule spans lines by design, so typing a
single `"` turned everything below it into string scope until the next quote β€”
a whole file going one color mid-edit. A KIP string never crosses a newline: the
lexer closes it there, and an escaped newline is invalid JSON, so `"a\` + newline
is a diagnostic either way. The rule now ends at end-of-line too, which is
exactly where the lexer ends it β€” the same lexer feeding the diagnostics in that
window, so the two stop disagreeing about where the string was.

**Folding counted braces inside strings and comments.** The fallback path
scanned raw characters, so `{name: "a { b"}` and `// close the } later` pushed
and popped the brace stack and shifted every marker after them. That path runs
precisely when `parse` failed, i.e. when a brace inside a half-typed string is
most likely. It reads the lexer's tokens now; `tokenize` is total, so it still
works on exactly the input that defeated the parser.

**The editor never applied the protocol's parser budgets.** `diagnose` does not
call `checkBudget` on purpose β€” a budget is the embedder's call β€” but the
extension is an embedder and was not making it, so a document past
`MAX_KIP_INPUT_LEN` or the nesting ceiling showed no problems in an editor while
every KIP engine refuses it with `KIP_4002`. Telling the author that is what a
linter is for.

**Brackets auto-closed inside strings and comments**, where a closing character
is text rather than structure.

The grammar-sync test compared keyword lists by substring, which any rule,
comment or longer word containing those letters satisfies β€” a keyword dropped
from an alternation would still have passed. It compares sets now, both
directions; the current grammar and library agree on all 134 words. Three
regression tests added for the fixes above, at the level this suite can reach
without a VS Code host: the grammar's own `end` pattern, and the lexer
properties the folding fallback and the budget check depend on.

Not changed: `FormattingOptions.insertSpaces` is still ignored, so an editor
configured for tabs gets spaces. Supporting it means a new `FormatOptions` flag
in `kip-lang`, and whether `.kip` should indent with tabs at all is a house-style
call rather than a defect.

11 tests pass; `tsc --noEmit` and the esbuild bundle are clean, and the bundle
carries both `kip-lang` 2.0.2 fixes.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Assets 2
Loading