From d64357894f7cefa94a96f4b2e4b9cdb334a0d87a Mon Sep 17 00:00:00 2001 From: Akianonymus Date: Tue, 13 Sep 2022 17:57:27 +0530 Subject: buffer_utils: A very vague commit message --- lua/colorizer/buffer_utils.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lua/colorizer/buffer_utils.lua b/lua/colorizer/buffer_utils.lua index 7801d0c..9a48043 100644 --- a/lua/colorizer/buffer_utils.lua +++ b/lua/colorizer/buffer_utils.lua @@ -137,9 +137,8 @@ local function highlight_buffer_tailwind(buf, ns, mode, options) local first_col = color.range.start.character local end_col = color.range["end"].character - local d = datas[cur_line] or {} - table.insert(d, { name = name, range = { first_col, end_col } }) - datas[cur_line] = d + datas[cur_line] = datas[cur_line] or {} + table.insert(datas[cur_line], { name = name, range = { first_col, end_col } }) end add_highlight(options, buf, ns, datas, line_start or 0, line_end and (line_end + 2) or -1) end @@ -183,15 +182,15 @@ function highlight_buffer(buf, ns, lines, line_start, line_end, options, options local mode = options.mode == "background" and { mode = "background" } or { mode = "foreground" } for current_linenum, line in ipairs(lines) do current_linenum = current_linenum - 1 + line_start + data[current_linenum] = data[current_linenum] or {} + -- Upvalues are options and current_linenum local i = 1 while i < #line do local length, rgb_hex = loop_parse_fn(line, i, buf) if length and rgb_hex then local name = create_highlight(rgb_hex, mode) - local d = data[current_linenum] or {} - table.insert(d, { name = name, range = { i - 1, i + length - 1 } }) - data[current_linenum] = d + table.insert(data[current_linenum], { name = name, range = { i - 1, i + length - 1 } }) i = i + length else i = i + 1 -- cgit v1.2.3-70-g09d2