insertText method
Inserts text at the specified line and character position.
line is zero-based (0 for the first line).
character is zero-based column position within the line.
The character position will be clamped to the line's length.
Implementation
void insertText(String text, int line, int character) {
if (readOnly) return;
_flushBuffer();
// Clamp line to valid range
final clampedLine = line.clamp(0, lineCount - 1);
// Get the line text to clamp character position
final lineText = getLineText(clampedLine);
final clampedChar = character.clamp(0, lineText.length);
// Calculate the offset
final offset = getLineStartOffset(clampedLine) + clampedChar;
// Insert the text
replaceRange(offset, offset, text);
}