| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
do, ->, and open brackets at the end of a line indent the next line (( never did); end and closing brackets dedent, also when more follows (end), }, ]). else, rescue, catch, and after close one branch and open the next. A binary operator at the end of a line (x =, <>, and, when, ::) continues the expression on the next line only. The patterns allow a trailing comment, and "Todo" or ~r/.../ no longer look like `do` or an operator. Comment lines don't change the indentation, so "# what to do" doesn't indent the next line. HEEx and HTML (EEx) templates indent inside open tags, multi-line open tags, and <%= ... do %> blocks. On the formatted code of Elixir, Phoenix, LiveView, and Ecto, a typed line gets the formatter's indentation 87.3% of the time, up from 82.3%, and 94.4% in ~H templates, up from 49%. The rest are layouts TextMate's indentation can't express, such as clauses after a multi-line clause body and arguments aligned to a column. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Formatted Elixir nests by indentation, so a line that opens a block (do, ->, an open bracket, else/rescue/catch/after, or a continued expression) folds the lines indented below it. Before, only the else branch of an if folded, clauses and brackets closed by `},`, `])`, and the like never did, and heredocs and docs didn't fold. Heredocs, docs, and ~H/~L templates fold from the line that opens them to their closing delimiter. The opening line is told apart from the closing one by the scope at the end of the line. Template lines fold by their tags. Comment lines have no fold marker. The grammar's foldingStartMarker/foldingStopMarker are removed; they were only used when no preference sets fold patterns. On the formatted corpus, a line ending in do, ->, or an open bracket that is followed by an indented block folds 99.9%, 99.98%, and 97% of the time, and 3.9% of fold markers fold nothing, down from 23%. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ExUnit describe and test blocks are listed by name, with tests indented; the grammar gives their names a meta.describe/meta.test scope. - @type, @TypeP, and @opaque names are listed as types. - Protocols and implementations are listed as "Size (protocol)" and "Size for Map (implementation)". They set only symbolIndexTransformation, which TextMate doesn't read, so they showed the raw `defimpl ... do`. - Module names no longer lose a "do" inside them ("Todo"). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
test/editing computes them from the preferences the way TextMate does (indent::fsm_t, folds_t::foldable_ranges, symbols_t, and the ranking of scope selectors in scope::selector_t, checked against TextMate's own code), with Oniguruma regexes. Every code line of the fixtures must be indented as it is, and the folds, fold markers without a fold, and symbols must match the snapshots. npm test runs it after the grammar tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| Back | FazBrowse Home | New Git URL |
Step 2 of the plan: editing behavior. Each change was measured against the formatted code of Elixir 1.20.4, Phoenix, LiveView and Ecto (1,037 files, 281k code lines), using ports of TextMate's own algorithms. It's covered by a new test that runs in CI.
Indentation
Result: a typed line gets the formatter's indentation 87.3% of the time, up from 82.3%. Inside ~H templates it's 94.4%, up from 49%. The misses are layouts TextMate's indentation can't express:
Folding
Result:
Heredocs whose closing delimiter is aligned with the opening line fold 98% of the time. Gutter markers that fold nothing drop from 23% to 3.9%. TextMate shows a marker on every line that matches a start pattern, so block starts are specific patterns, not "any line".
The grammar's foldingStartMarker/foldingStopMarker are removed. TextMate only used them when no preference sets fold patterns.
Symbol list
How TextMate picks these preferences
Tests
test/editing/test.js (run by npm test) computes indentation, folding and symbols the way TextMate does, with Oniguruma regexes:
Test plan
🤖 Generated with Claude Code