Expand description
Read-only code, with line numbers and marked lines.
§No grammar, and no new dependency
Deciding that a word is a keyword needs a grammar, which is the same kind
of fact the calendar is: answered correctly only by the library the
application already depends on. docs/coverage.md records syntax
highlighting as out of scope, and this view keeps that line — it takes
pre-classified spans from the caller, exactly as Markdown colours a
fenced block.
What the caller owes, per line:
- the line’s own text, with no newline in it;
CodeSpanranges in byte offsets into that line’s text, not into the whole document, on character boundaries;- ranges sorted ascending and not overlapping.
A span that breaks any of those is skipped rather than drawn wrongly: the
line stays readable without its colour, and colour that landed in the wrong
place would be a lie about the code. This is the same boundary
crate::display::highlight states for search hits, and it is deliberately
the same one.
§Long lines scroll, they do not wrap
In prose a wrap is invisible; in code a column carries meaning. Indentation is structure, an aligned comment is a column, and a diagnostic that says “column 34” is pointing at a place a wrapped line no longer has. Wrapping also breaks the one thing the gutter claims — that line 41 is one row — so a marked line would stop lining up with its mark. So a long line runs off the edge and the view scrolls to it.
§Size, and what virtualization costs here
With no CodeView::visible_lines every line is laid out inside a
ScrollArea that scrolls both ways, which is
the mode that keeps the horizontal scroll above.
With visible_lines the body becomes the virtualized List, which draws
only the rows the viewport holds — and then the horizontal scroll goes,
for the reason DataGrid already states: uniform_list owns its own
scroll offset and lays every row out at the width it is given. A long line
is clipped at the frame in that mode. The two are named rather than
blended, because a view that silently dropped the right-hand half of a line
would be worse than one that says which mode it is in.
§Copying
GPUI offers no text-selection primitive, which docs/coverage.md records
as a library-wide gap; nothing rendered here can be selected with a
pointer. So the view carries a control that copies the whole text, the way
a Markdown code block does, and does not pretend a caret exists.
Structs§
Enums§
- Line
Mark - What a line is being called out for.