From 715108b08bcb671defbcb9ad0250f38f47d5487e Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Thu, 11 Aug 2022 16:58:06 -0400 Subject: [PATCH] fix(textarea): better SeekInner and SeekAround --- textarea/modal.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/textarea/modal.go b/textarea/modal.go index e48afa6..e39d811 100644 --- a/textarea/modal.go +++ b/textarea/modal.go @@ -566,6 +566,11 @@ func (m *Model) findPairRange(r rune) Range { var startRune, endRune rune switch r { + case 'w', 'W': + return Range{ + Start: m.findWordLeft(0, r == 'W'), + End: m.findWordEndRight(1, true), + } case '(', ')': startRune, endRune = '(', ')' case '{', '}': @@ -576,6 +581,12 @@ func (m *Model) findPairRange(r rune) Range { startRune, endRune = '<', '>' case '"', '\'': startRune, endRune = r, r + default: + m.command = &NormalCommand{} + return Range{ + Start: Position{m.row, m.col}, + End: Position{m.row, m.col}, + } } return Range{ @@ -717,10 +728,7 @@ func (m *Model) deleteRange(r Range) { maxCol = min(maxCol+1, len(m.value[r.Start.Row])) } else if m.command.IsSeekingBackward() { minCol = max(minCol-1, 0) - } else if m.command.Seeking == SeekAround { - maxCol = min(maxCol+1, len(m.value[r.Start.Row])) - minCol = max(minCol-1, 0) - } else if m.command.Seeking == SeekInner { + } else if m.command.Seeking == SeekAround || m.command.Seeking == SeekInner { maxCol = min(maxCol+1, len(m.value[r.Start.Row])) } }