fix: edge cases with {d,c}iw and {d,c}aw

This commit is contained in:
Maas Lalani 2022-08-11 17:13:26 -04:00
parent 715108b08b
commit 0f1a912f12
No known key found for this signature in database
GPG Key ID: 5A6ED5CBF1A0A000

View File

@ -246,6 +246,10 @@ func (m *Model) normalUpdate(msg tea.Msg) tea.Cmd {
if len(msg.Runes) <= 0 {
m.command = &NormalCommand{}
}
if msg.Runes[0] == 'w' || msg.Runes[0] == 'W' {
m.command.Range = m.findPairRange(msg.Runes[0])
return executeCmd(*m.command)
}
switch m.command.Buffer {
case "a":
m.command.Range = m.findPairRange(msg.Runes[0])
@ -554,10 +558,10 @@ func (m *Model) findCharRight(r rune) Position {
col := m.col
for col < len(m.value[m.row]) {
col++
if m.value[m.row][col] == r {
return Position{m.row, col}
}
col++
}
return Position{m.row, m.col}
}
@ -604,6 +608,13 @@ func (m *Model) findWordLeft(count int, ignorePunctuation bool) Position {
wordBreak = isWordBreak
}
if count == 0 {
if wordBreak(m.value[m.row][m.col-1]) {
return Position{m.row, m.col}
}
count = 1
}
row, col := m.row, m.col
for count > 0 {