From 1166a67c6403945b395d8708a43eeb9b3966d895 Mon Sep 17 00:00:00 2001 From: Hayden Hargreaves Date: Sat, 4 Apr 2026 11:38:19 -0700 Subject: [PATCH] fix: updated via using feedback from Qodo --- internal/motion/word.go | 22 ++++++++++++++++++++-- internal/operator/yank.go | 4 ++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/internal/motion/word.go b/internal/motion/word.go index 97f152c..91c0087 100644 --- a/internal/motion/word.go +++ b/internal/motion/word.go @@ -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 } @@ -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 } diff --git a/internal/operator/yank.go b/internal/operator/yank.go index cd2135b..e162fbc 100644 --- a/internal/operator/yank.go +++ b/internal/operator/yank.go @@ -87,6 +87,10 @@ func yankNormalMode(m action.Model, start, end core.Position, mtype core.MotionT cnt := line[startX:endX] m.UpdateDefaultRegister(core.CharwiseRegister, []string{cnt}) + win := m.ActiveWindow() + win.SetCursorCol(startX) + win.SetCursorLine(start.Line) + case mtype == core.Linewise: // These don't need to be validated, they are validated before being passed into the function startY := min(start.Line, end.Line)