@@ -390,16 +390,16 @@ export class Editor implements Component, Focusable {
|
||||
// Returned to "current" state - clear editor
|
||||
this.setTextInternal("");
|
||||
} else {
|
||||
this.setTextInternal(this.history[this.historyIndex] || "");
|
||||
this.setTextInternal(this.history[this.historyIndex] || "", direction === -1 ? "start" : "end");
|
||||
}
|
||||
}
|
||||
|
||||
/** Internal setText that doesn't reset history state - used by navigateHistory */
|
||||
private setTextInternal(text: string): void {
|
||||
private setTextInternal(text: string, cursorPlacement: "start" | "end" = "end"): void {
|
||||
const lines = text.split("\n");
|
||||
this.state.lines = lines.length === 0 ? [""] : lines;
|
||||
this.state.cursorLine = this.state.lines.length - 1;
|
||||
this.setCursorCol(this.state.lines[this.state.cursorLine]?.length || 0);
|
||||
this.state.cursorLine = cursorPlacement === "start" ? 0 : this.state.lines.length - 1;
|
||||
this.setCursorCol(cursorPlacement === "start" ? 0 : this.state.lines[this.state.cursorLine]?.length || 0);
|
||||
// Reset scroll - render() will adjust to show cursor
|
||||
this.scrollOffset = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user