diff --git a/lua/precognition/init.lua b/lua/precognition/init.lua index c90fb14..6d085eb 100644 --- a/lua/precognition/init.lua +++ b/lua/precognition/init.lua @@ -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" }) @@ -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), diff --git a/tests/precognition/virtline_spec.lua b/tests/precognition/virtline_spec.lua index 4534ffe..4d76727 100644 --- a/tests/precognition/virtline_spec.lua +++ b/tests/precognition/virtline_spec.lua @@ -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)