feat: adding word actions, not done, and lots of failing tests #4

Merged
azpect merged 15 commits from feature/word-motions into master 2026-04-04 11:43:47 -07:00
2 changed files with 24 additions and 2 deletions
Showing only changes of commit 1166a67c64 - Show all commits

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
}
@ -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
}

View File

@ -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)