Skip to content

Commit

Permalink
refactor: minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
tris203 committed Jun 1, 2024
1 parent 6868da4 commit 7e8b682
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
6 changes: 1 addition & 5 deletions lua/precognition/horizontal_motions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,7 @@ 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
--if remaining string is whitespace, return 0
local remaining = string.sub(str, offset)
if remaining:match("^%s*$") and #remaining > 0 then
return 0
Expand Down
3 changes: 2 additions & 1 deletion lua/precognition/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ M.char_classes = {
other = 1,
word = 2,
emoji = 3,
UNKNOWN = -1,
}

---@param char string
Expand All @@ -17,7 +18,7 @@ function M.char_class(char, big_word)

local byte = string.byte(char)
if byte == nil then
return cc.other
return cc.UNKNOWN
end
if char == " " or char == "\t" or char == "\0" then
return cc.whitespace
Expand Down
1 change: 1 addition & 0 deletions tests/precognition/char_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe("static classes", function()
eq(cc.other, 1)
eq(cc.word, 2)
eq(cc.emoji, 3)
eq(cc.UNKNOWN, -1)
end)
end)

Expand Down

0 comments on commit 7e8b682

Please sign in to comment.