fix: updated via using feedback from Qodo
All checks were successful
Run Test Suite / test (push) Successful in 20s
Run Test Suite / test (pull_request) Successful in 15s

This commit is contained in:
Hayden Hargreaves 2026-04-04 11:38:19 -07:00
parent b23072b43f
commit 1166a67c64
2 changed files with 24 additions and 2 deletions

View File

@ -534,7 +534,19 @@ func prevWordEnd(buf *core.Buffer, x, y int) (int, int) {
} }
} }
// We're now at the end of the previous word - that's the answer! // Now x,y is at the start of the target word. Move forward to its end.
if x >= 0 {
if isWordChar(line[x]) {
for x+1 < len(line) && isWordChar(line[x+1]) {
x++
}
} else if isWordPunctuation(line[x]) {
for x+1 < len(line) && isWordPunctuation(line[x+1]) {
x++
}
}
}
return x, y return x, y
} }
@ -594,7 +606,13 @@ func prevWORDEnd(buf *core.Buffer, x, y int) (int, int) {
} }
} }
// We're now at the end of the previous WORD - that's the answer! // Now x,y is at the start of the target WORD. Move forward to its end.
if x >= 0 {
for x+1 < len(line) && line[x+1] != ' ' && line[x+1] != '\t' {
x++
}
}
return x, y return x, y
} }

View File

@ -87,6 +87,10 @@ func yankNormalMode(m action.Model, start, end core.Position, mtype core.MotionT
cnt := line[startX:endX] cnt := line[startX:endX]
m.UpdateDefaultRegister(core.CharwiseRegister, []string{cnt}) m.UpdateDefaultRegister(core.CharwiseRegister, []string{cnt})
win := m.ActiveWindow()
win.SetCursorCol(startX)
win.SetCursorLine(start.Line)
case mtype == core.Linewise: case mtype == core.Linewise:
// These don't need to be validated, they are validated before being passed into the function // These don't need to be validated, they are validated before being passed into the function
startY := min(start.Line, end.Line) startY := min(start.Line, end.Line)