textSyntaxChangeWindow function
TextSyntaxChangeWindow
textSyntaxChangeWindow({
- required TextDocument previousDocument,
- required TextDocument nextDocument,
- required TextDocumentChange change,
- int lookBehindLines = 0,
- int lookAheadLines = 0,
Implementation
TextSyntaxChangeWindow textSyntaxChangeWindow({
required TextDocument previousDocument,
required TextDocument nextDocument,
required TextDocumentChange change,
int lookBehindLines = 0,
int lookAheadLines = 0,
}) {
final previousStartLine = (change.startPosition.line - lookBehindLines).clamp(
0,
previousDocument.lineCount,
);
final previousEndLine = (change.oldEndPosition.line + lookAheadLines + 1)
.clamp(previousStartLine, previousDocument.lineCount);
final nextStartLine = (change.startPosition.line - lookBehindLines).clamp(
0,
nextDocument.lineCount,
);
final nextEndLine = (change.newEndPosition.line + lookAheadLines + 1).clamp(
nextStartLine,
nextDocument.lineCount,
);
return TextSyntaxChangeWindow(
previousLines: TextSyntaxLineWindow(
startLine: previousStartLine,
endLine: previousEndLine,
),
nextLines: TextSyntaxLineWindow(
startLine: nextStartLine,
endLine: nextEndLine,
),
);
}