Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: leadmultispace and multispace #940

Merged
merged 1 commit into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading