Skip to content

Commit

Permalink
fix: don't overload copy of Vim char class.
Browse files Browse the repository at this point in the history
  • Loading branch information
tris203 committed Jun 1, 2024
1 parent 4492ba9 commit a373c38
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 4 additions & 0 deletions lua/precognition/horizontal_motions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ function M.prev_word_boundary(str, cursorcol, linelen, big_word)
while utils.char_class(char, big_word) == c_class and offset >= 0 do
offset = offset - 1
char = vim.fn.strcharpart(str, offset - 1, 1)
if char == "" then
-- Gone outside the line boundary, so break.
break
end
--if remaining string is whitespace, return nil_wrap
local remaining = string.sub(str, offset)
if remaining:match("^%s*$") and #remaining > 0 then
Expand Down
5 changes: 0 additions & 5 deletions tests/precognition/char_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ describe("big_word classing", function()
eq(utils.char_class("", false), 2)
eq(utils.char_class("", false), 2)
end)

it("can class the empty string", function()
eq(utils.char_class("", true), 3)
eq(utils.char_class("", false), 3)
end)
end)

describe("pad arrays", function()
Expand Down

0 comments on commit a373c38

Please sign in to comment.