package action import tea "github.com/charmbracelet/bubbletea" // DeleteChar implements Action (x) type DeleteChar struct { Count int } func (a DeleteChar) Execute(m Model) tea.Cmd { pos := m.CursorX() line := m.Line(m.CursorY()) for i := 0; i < a.Count && pos < len(line); i++ { line = line[:pos] + line[pos+1:] m.SetLine(m.CursorY(), line) } return nil } func (a DeleteChar) WithCount(n int) Action { return DeleteChar{Count: n} }