From fd22263c32d89cb7e18bb9a41c1400f70e752c68 Mon Sep 17 00:00:00 2001 From: hedy Date: Mon, 13 Nov 2023 16:48:06 +0800 Subject: [PATCH] fix: Guide and fold highlight offsets Was a silly mistake due to copying code from previous implementation. --- lua/outline/writer.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lua/outline/writer.lua b/lua/outline/writer.lua index d4b7c9c..ec55143 100644 --- a/lua/outline/writer.lua +++ b/lua/outline/writer.lua @@ -137,8 +137,8 @@ function M.make_outline(bufnr, items) local function add_guide_hl(from, to) table.insert(hl, { #flattened, - from + lineno_offset, - to + lineno_offset, + from, + to, "OutlineGuides" }) end @@ -146,8 +146,8 @@ function M.make_outline(bufnr, items) local function add_fold_hl(from, to) table.insert(hl, { #flattened, - from + lineno_offset, - to + lineno_offset, + from, + to, "OutlineFoldMarker" }) end @@ -202,12 +202,13 @@ function M.make_outline(bufnr, items) -- Finished with guide prefix -- Join all prefix chars by a space local pref_str = table.concat(pref, ' ') + local total_pref_len = lineno_offset + #pref_str -- Guide hl goes from start of prefix till before the fold marker, if any. -- Fold hl goes from start of fold marker until before the icon. - add_guide_hl(lineno_offset, #pref_str - fold_marker_width) + add_guide_hl(lineno_offset, total_pref_len - fold_marker_width) if fold_marker_width > 0 then - add_fold_hl(#pref_str - fold_marker_width, #pref_str + 1) + add_fold_hl(total_pref_len - fold_marker_width, total_pref_len + 1) end local line = lineno_prefix..pref_str..' '..node.icon..' '..node.name