Simplify UI/parser

This commit is contained in:
Yura Dupyn 2026-04-25 02:01:09 +02:00
parent f55b437037
commit a56020cd9f
3 changed files with 54 additions and 105 deletions

View file

@ -5,6 +5,7 @@ import {
NEW_LINE,
SPACE,
TAB,
containsIndex,
} from 'source-region';
import type {
CodePoint,
@ -123,8 +124,8 @@ function makeSourceGrid(source: SourceText, region: SourceRegion): SourceGridMod
for (let lineNo = region.span.start.line; lineNo <= region.span.end.line; lineNo++) {
const range = source.getLineRange(lineNo);
const start = Math.max(range.start, region.span.start.index);
const end = Math.min(range.end, region.span.end.index);
const start = Math.max(range.start, region.codePointSpan.start);
const end = Math.min(range.end, region.codePointSpan.end);
const cells: SourceGridCell[] = [];
for (let index = start; index < end; index++) {
@ -183,8 +184,7 @@ function cellTitle(cell: SourceGridCell, annotations: SourceGridAnnotation[]): s
function annotationsForCell(cell: SourceGridCell, annotations: SourceGridAnnotation[]): SourceGridAnnotation[] {
return annotations.filter((annotation) =>
annotation.span.start < annotation.span.end
&& annotation.span.start <= cell.index
&& cell.index < annotation.span.end
&& containsIndex(annotation.span, cell.index)
);
}