Skip to content

Commit

Permalink
fix: e motion - behind cursor
Browse files Browse the repository at this point in the history
  • Loading branch information
tris203 committed May 15, 2024
1 parent ba2147d commit a9a1b1d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lua/precognition/horizontal_motions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ function M.end_of_word(str, cursorcol, _linelen)
end

if rev_offset ~= nil then
--e should never be behind the cursor
if rev_offset < cursorcol then
return 0
end
return rev_offset
end
return offset - 1
Expand Down
5 changes: 5 additions & 0 deletions tests/precognition/horizontal_motions_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,9 @@ describe("edge case", function()
eq(1, hm.prev_word_boundary(str, 6, #str))
eq(7, hm.end_of_word(str, 6, #str))
end)

it("strings with spaces at the end", function()
local str = "there is a space "
eq(0, hm.end_of_word(str, 16, #str))
end)
end)

0 comments on commit a9a1b1d

Please sign in to comment.