Skip to content

Commit

Permalink
fix: hint precendce
Browse files Browse the repository at this point in the history
  • Loading branch information
tris203 committed Apr 30, 2024
1 parent f13e0f2 commit 314d430
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lua/precognition/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ local function build_virt_line(marks, line_len)
local col = loc

if col ~= nil then
line = line:sub(1, col - 1) .. hint .. line:sub(col + 1)
if line:sub(col, col) == " " then
line = line:sub(1, col - 1) .. hint .. line:sub(col + 1)
end
end
end
table.insert(virt_line, { line, "Comment" })
Expand Down Expand Up @@ -260,6 +262,8 @@ local function on_cursor_hold()
-- get char offsets for more complex motions.

local virt_line = build_virt_line({
--WARN: The order of this list sets the precedence of the hints
--If multiple hints target the same column, the first one in the list will be used
["w"] = next_word_boundary(cur_line, cursorcol),
["e"] = end_of_word(cur_line, cursorcol),
["b"] = prev_word_boundary(cur_line, cursorcol),
Expand Down
2 changes: 1 addition & 1 deletion tests/precognition/virtline_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe("Build Virtual Line", function()
["$"] = line_len,
}, line_len)

eq("^ e w $", virt_line[1][1])
eq("b e w $", virt_line[1][1])
eq(#line, #virt_line[1][1])
end)

Expand Down

0 comments on commit 314d430

Please sign in to comment.