Skip to content

Commit e51b651

Browse files
committed
fix: leadmultispace and multispace
fix #939
1 parent 04e44b0 commit e51b651

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

lua/ibl/virt_text.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ M.get = function(
8484
local indent_hl
8585
local underline_hl
8686
local sa = scope_active
87-
local char = get_char(char_map[ws], indent_index)
87+
local char = get_char(char_map[ws], (ws == whitespace.SPACE and i) or indent_index)
8888

8989
if indent.is_indent(ws) then
9090
whitespace_hl = utils.tbl_get_index(highlights.whitespace, indent_index).char

specs/features/virt_text_spec.lua

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,4 +695,45 @@ describe("virt_text", function()
695695
{ "e", { "@ibl.whitespace.char.3", "@ibl.scope.underline.2" } },
696696
})
697697
end)
698+
699+
it("renders lead and multi lead spaces correctly", function()
700+
local config = conf.set_config()
701+
highlights.setup()
702+
local char_map = {
703+
[TAB_START] = "a",
704+
[TAB_START_SINGLE] = "b",
705+
[TAB_FILL] = "c",
706+
[TAB_END] = "d",
707+
[SPACE] = { "e", "f", "g" },
708+
[INDENT] = "h",
709+
}
710+
local whitespace_tbl = { INDENT, SPACE, SPACE, SPACE, INDENT, SPACE, SPACE, SPACE }
711+
local scope_active = false
712+
local scope_index = -1
713+
local scope_start = false
714+
local scope_end = false
715+
local scope_col_start_single = 0
716+
717+
local virt_text = vt.get(
718+
config,
719+
char_map,
720+
whitespace_tbl,
721+
scope_active,
722+
scope_index,
723+
scope_start,
724+
scope_end,
725+
scope_col_start_single
726+
)
727+
728+
assert.are.same(virt_text, {
729+
{ "h", { "@ibl.whitespace.char.1", "@ibl.indent.char.1" } },
730+
{ "f", { "@ibl.whitespace.char.1" } },
731+
{ "g", { "@ibl.whitespace.char.1" } },
732+
{ "e", { "@ibl.whitespace.char.1" } },
733+
{ "h", { "@ibl.whitespace.char.1", "@ibl.indent.char.1" } },
734+
{ "g", { "@ibl.whitespace.char.1" } },
735+
{ "e", { "@ibl.whitespace.char.1" } },
736+
{ "f", { "@ibl.whitespace.char.1" } },
737+
})
738+
end)
698739
end)

0 commit comments

Comments
 (0)