From cf7310dbe6529baaed1ca48345ba96e9c266dabc Mon Sep 17 00:00:00 2001 From: Ashkan Kiani Date: Thu, 2 Jan 2020 15:05:55 -0800 Subject: Bugfix for no matches and trim extra width. --- lua/colorizer.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lua/colorizer.lua') diff --git a/lua/colorizer.lua b/lua/colorizer.lua index 1dbb392..e3db358 100644 --- a/lua/colorizer.lua +++ b/lua/colorizer.lua @@ -837,7 +837,8 @@ local function color_picker(starting, on_change) local winnr = api.nvim_open_win(bufnr, true, { style = 'minimal'; -- anchor = 'NW'; - width = bar_width + 10; + -- The required extra width is 6. Anything after is for padding. + width = bar_width + 6 + 1; relative = 'cursor'; row = 0; col = 0; height = 4; @@ -880,11 +881,11 @@ local function color_picker_on_cursor(config) start = start or col+1 local prefix = line:sub(1, start-1) local suffix = line:sub(start+(length or 0)) - local matched = line:sub(start, start+length) local formatter = function(rgb) return "#"..rgb_to_hex(unpack(rgb)) end - if match_format then + if match_format and length then + local matched = line:sub(start, start+length) -- TODO(ashkan): make matching the result optional? if startswith(matched, "rgba") then -- TODO(ashkan): support alpha? -- cgit v1.2.3-70-g09d2