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