From 438e887d6f9eb462280a22ec0d42aead7bbf1c07 Mon Sep 17 00:00:00 2001 From: Kyren223 Date: Wed, 18 Dec 2024 18:10:56 +0200 Subject: Fixed motion counts only going up to 9 in viminput --- internal/client/ui/core/chat/chat.go | 2 +- internal/client/ui/viminput/viminput.go | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'internal/client/ui') diff --git a/internal/client/ui/core/chat/chat.go b/internal/client/ui/core/chat/chat.go index 00f5837..181167f 100644 --- a/internal/client/ui/core/chat/chat.go +++ b/internal/client/ui/core/chat/chat.go @@ -15,7 +15,7 @@ type Model struct { } func New() Model { - vi := viminput.New(90, 5) + vi := viminput.New(90, 20) vi.Placeholder = "Send a message..." vi.PlaceholderStyle = lipgloss.NewStyle().Foreground(colors.Gray) vi.LineDecoration = func(lnum int, m viminput.Model) string { diff --git a/internal/client/ui/viminput/viminput.go b/internal/client/ui/viminput/viminput.go index 850b9e3..18f4c89 100644 --- a/internal/client/ui/viminput/viminput.go +++ b/internal/client/ui/viminput/viminput.go @@ -418,15 +418,17 @@ func (m *Model) handleNormalModeKeys(key tea.KeyMsg) { return } + motion := key.String() + count := 1 - if m.count != NoCount { + if m.count != NoCount && (motion[0] < '0' || motion[0] > '9'){ count = m.count m.count = NoCount } shouldReturn := false for i := 0; i < count; i++ { - line, col := m.Motion(key.String()) + line, col := m.Motion(motion) if line != Unchanged { m.SetCursorLine(line) shouldReturn = true @@ -1621,7 +1623,8 @@ func (m *Model) handleVisualModeKeys(key tea.KeyMsg) { return } - if key.String() == "o" { + motion := key.String() + if motion == "o" { line, col := m.vline, m.vcol m.vline = m.cursorLine m.vcol = m.cursorColumn @@ -1631,12 +1634,11 @@ func (m *Model) handleVisualModeKeys(key tea.KeyMsg) { } count := 1 - if m.count != NoCount { + if m.count != NoCount && (motion[0] < '0' || motion[0] > '9'){ count = m.count m.count = NoCount } - motion := key.String() shouldReturn := false for i := 0; i < count; i++ { line, col := m.Motion(motion) @@ -1792,7 +1794,8 @@ func (m *Model) handleVisualLineModeKeys(key tea.KeyMsg) { return } - if key.String() == "o" { + motion := key.String() + if motion == "o" { line, col := m.vline, m.vcol m.vline = m.cursorLine m.vcol = m.cursorColumn @@ -1802,12 +1805,11 @@ func (m *Model) handleVisualLineModeKeys(key tea.KeyMsg) { } count := 1 - if m.count != NoCount { + if m.count != NoCount && (motion[0] < '0' || motion[0] > '9'){ count = m.count m.count = NoCount } - motion := key.String() shouldReturn := false for i := 0; i < count; i++ { line, col := m.Motion(motion) -- cgit v1.3.1