Skip to main content

Module editor_lines

Module editor_lines 

Source
Expand description

fileindexlines: where the lines of a text file start, for the Large text viewer. The file is read here, in blocks, once per (path, modified time): what is kept is the byte offset of every STEP-th line, so the viewer asks for “lines 5,000,000 to 5,000,100” and gets the byte range to fetch, and a file bigger than memory never leaves srv. A line ends at \n (so \r\n and \n files both work); in UTF-16 it ends at the two-byte \n. A final line with no newline is a line; a newline at the very end starts none.

docs/specs/SPEC_EDITOR_REVAMP_UNIFIED_VIEWERS_2026_10_15.md §4.4.6.

Structs§

LineIndex
Where the lines of one file start, as of one (size, mtime).

Enums§

Unit
How a file’s text marks the end of a line.

Functions§

build_index
Reads file (size bytes) front to back and notes where every step-th line starts.
detect_encoding
The WHATWG name of the encoding of the text that file holds, from its start: UTF-16 as the unit says, else a UTF-8 BOM, else valid UTF-8 (a character cut at the end of the sample is not an error), else the detector’s guess, as the Editor’s own reader makes it. The probe says only “legacy” for a file that isn’t UTF-8.
line_of
The line (0-based) that holds byte offset: the last one that starts at or before it. An offset past the end is in the last line. Reads from the nearest checkpoint to offset, counting breaks, so at most STEP lines.
line_start
Where line line (0-based) starts; the size for a line past the last.
register
fileindexlines. This computer’s files only, like fileprobe.