Forgot this

This commit is contained in:
Hayden Hargreaves 2026-02-08 23:25:38 -07:00
parent e7405a8d19
commit 4003f411e0

View File

@ -96,22 +96,22 @@ func (m *model) replayInsert() {
func (m *model) processInsertKey(key string) { func (m *model) processInsertKey(key string) {
switch key { switch key {
case "enter": case "enter":
y := m.cursor.y y := m.cursor.y
x := m.cursor.x x := m.cursor.x
// Simple case, at end, just create a line // Simple case, at end, just create a line
if x == len(m.lines[y]) { if x == len(m.lines[y]) {
m.lines = append(m.lines[:y+1], append([]string{""}, m.lines[y+1:]...)...) m.lines = append(m.lines[:y+1], append([]string{""}, m.lines[y+1:]...)...)
// otherwise, splice // otherwise, splice
} else { } else {
l := m.lines[y] l := m.lines[y]
m.lines[y] = l[:x] m.lines[y] = l[:x]
m.lines = append(m.lines[:y+1], append([]string{l[x:]}, m.lines[y+1:]...)...) m.lines = append(m.lines[:y+1], append([]string{l[x:]}, m.lines[y+1:]...)...)
} }
m.cursor.y++ m.cursor.y++
m.cursor.x = 0 m.cursor.x = 0
case "backspace": case "backspace":
x := m.cursor.x x := m.cursor.x