Skip to content

Commit

Permalink
fix: leadmultispace and multispace
Browse files Browse the repository at this point in the history
fix #939
  • Loading branch information
lukas-reineke committed Nov 10, 2024
1 parent 04e44b0 commit d1323e5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lua/ibl/virt_text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ M.get = function(
local indent_hl
local underline_hl
local sa = scope_active
local char = get_char(char_map[ws], indent_index)
local char = get_char(char_map[ws], (ws == whitespace.SPACE and i) or indent_index)

if indent.is_indent(ws) then
whitespace_hl = utils.tbl_get_index(highlights.whitespace, indent_index).char
Expand Down
41 changes: 41 additions & 0 deletions specs/features/virt_text_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -695,4 +695,45 @@ describe("virt_text", function()
{ "e", { "@ibl.whitespace.char.3", "@ibl.scope.underline.2" } },
})
end)

it("renders lead and multi lead spaces correctly", function()
local config = conf.set_config()
highlights.setup()
local char_map = {
[TAB_START] = "a",
[TAB_START_SINGLE] = "b",
[TAB_FILL] = "c",
[TAB_END] = "d",
[SPACE] = { "e", "f", "g" },
[INDENT] = "h",
}
local whitespace_tbl = { INDENT, SPACE, SPACE, SPACE, INDENT, SPACE, SPACE, SPACE }
local scope_active = false
local scope_index = -1
local scope_start = false
local scope_end = false
local scope_col_start_single = 0

local virt_text = vt.get(
config,
char_map,
whitespace_tbl,
scope_active,
scope_index,
scope_start,
scope_end,
scope_col_start_single
)

assert.are.same(virt_text, {
{ "h", { "@ibl.whitespace.char.1", "@ibl.indent.char.1" } },
{ "f", { "@ibl.whitespace.char.1" } },
{ "g", { "@ibl.whitespace.char.1" } },
{ "e", { "@ibl.whitespace.char.1" } },
{ "h", { "@ibl.whitespace.char.1", "@ibl.indent.char.1" } },
{ "g", { "@ibl.whitespace.char.1" } },
{ "e", { "@ibl.whitespace.char.1" } },
{ "f", { "@ibl.whitespace.char.1" } },
})
end)
end)

0 comments on commit d1323e5

Please sign in to comment.