Skip to content

Hang a file's wrapped rows from their indent - #6770

Merged
max-sixty merged 12 commits into
mainfrom
editor-leftovers
Nov 23, 2026
Merged

max-sixty merged 12 commits into
mainfrom
editor-leftovers

Conversation

@max-sixty

@max-sixty max-sixty commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Fixes a file editor leftover from #6019: on a phone, a wrapped YAML row started at the editor's edge, like a new key.

Wrapped rows hang from their line's indent. Rows now start two columns past the indent, behind the ↪ mark code blocks use. That hang now has one rule, in marks.css, which the document, every shadow stage and now the composer adopt; code blocks, drafts and the editor mark their lines data-lf-pre-line and state only their padding. lf-code keeps its own, since its ::before is the line number.

The editor takes the look code blocks and the reply box already have, so a file wraps the same way in each. Max left the pick to me. The alternative was rows at the indent with no mark, as VS Code does: it would give the editor a look of its own, and at phone width a wrapped row then reads as a value under its key.

To weigh: the core bundle exports CodeMirror's countColumn; the write watch allows CodeMirror's restated line style.

Left out: the marks for a write that rewrites a line and removes the next ones stay as on main, on Max's pick; YAML number and boolean colours merged as #6776; a plain link to a pane no longer moves the page on main.

Tests: a phone check of where wrapped rows start, and one runtime case for a rewrapped paragraph's marks; pnpm run test:runtime.

This was written by Claude Code on behalf of max-sixty

…d rows from their indent

Two leftovers of the file editor from #6019.

A write from elsewhere whose one change rewrote a line and took the next ones away
marked the rewritten line and drew no rule for the lines it removed: the gap rule was
drawn only for a change that put no changed line in their place. The rule now follows
the lines a change marks wherever it left fewer lines than it replaced, the same rule a
pure removal draws, below the last line where the gap ends the file. A line can now
carry its mark and a gap rule together, so the gap no longer gives way to a mark on the
same line. tests/runtime/file-editor-writes.test.mjs gains both cases, which failed
before.

A long line in the editor wrapped onto rows that started at the editor's edge, so on a
phone a wrapped row of indented YAML read as a new top-level key. Each row after a
line's first now hangs two columns past the line's indent, behind the mark a code
block's wrapped rows wear, as the reading face's code blocks and a draft's code lines
already do. The editor states each visible line's indent through a line decoration,
counted with CodeMirror's own countColumn, which the core bundle now exports.
test_file_editor_long_filename_keeps_the_phone_editable now also checks that every
wrapped row of an indented line starts past the line's first word; before, they started
at the edge.
…watch

CodeMirror's Tile.sync assigns a line's style.cssText whenever any of its
attributes change, without comparing it, as the active line's class and a
written mark change it. The file editor's lines now state their indent in
their style, so test_file_editor_takes_in_an_outside_write_to_other_lines
reported those restatements as unchanged writes.

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The editor theme restates the code block's wrap hang instead of sharing it; see the inline note.

Comment thread packages/file-editor/widgets/editor.js Resolved
The rule for a rewrite that also took lines away judged each change of the
character diff on its own, so a rewrapped paragraph, whose changes join one line
to the next and split another, drew a gap rule between lines it only rewrote:
"aaa\nbbb ccc" written as "aaa bbb\nccc" marked both lines and a gap. Two changes
meeting inside a line neither changed also read each other's lines.

The marks now come from jsdiff's diff of the two versions' lines: each line put in
is marked, and a run of changes that took away more lines than it put in draws the
gap after the lines it put in. That deletes the per-change reading of lines, its
trimming of the lines a change's ends share, and the "wo\nt" reasoning behind it.
A line with a gap above and below now shows both rules; the per-line map kept one.

file-editor-writes.test.mjs gains the rewrap, which the previous commit marked with
a gap, and lines taken from both sides of a line, which main marked with one rule.
The hang now counts only spaces and tabs as indent, as a code block does.
…adopts

The hang of a wrapped code line, its formula, its hanging text-indent and the
masked ↪ before its rows, stood in reading.css for a code block's boxed lines, in
the composer's sheet for a draft's code lines, and, since the last commits, in the
file editor's theme. It now stands once in marks.css, keyed on `data-lf-pre-line`:
the document and every declared shadow stage already adopt that sheet, and the
composer's root now adopts it too. Each owner marks its lines and states only what
differs, the padding its mark stands past (`--lf-pre-line-inset`): the composer
its code box's inset, the file editor its line padding, a code block's line none.
The rule sits in lf-base, so a page's own rules still outrank it, as they outranked
the reading face's copy.

lf-code keeps its own hang (code.css): its lines' `::before` is the line number, so
the shared mark would draw over its gutter.

Checked: test_a_wrapped_row_hangs_from_its_line_s_indent_behind_a_mark (code
block hang 6ch, mark at 4ch), the phone file editor test, and Firefox captures of
a draft's wrapped code line and the editor's, each pixel-identical to before.
# Conflicts:
#	browser/vendor/codemirror.esm.js
The maintainer chose on 23 November to leave the marks as they are on main: a
write that rewrites a line and removes the next ones tints the rewritten line
and draws no rule, as VS Code and JetBrains do. The rule under the rewritten
line joined its bar into a box. This takes the line-diff marking, the jsdiff
import and the combined gap rule back out, and with them the three cases that
expected a rule beside a rewritten line or two rules on one line.

Kept as a test: a rewrapped paragraph marks its lines and no gap, which main's
marking already does.
@max-sixty max-sixty changed the title Mark the lines an agent's rewrite took away, and hang a file's wrapped rows from their indent Hang a file's wrapped rows from their indent Nov 23, 2026
@max-sixty
max-sixty marked this pull request as ready for review November 23, 2026 20:04
@max-sixty
max-sixty merged commit 4a31325 into main Nov 23, 2026
7 checks passed
@max-sixty
max-sixty deleted the editor-leftovers branch November 23, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants