aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshkan Kiani <ashkan.k.kiani@gmail.com>2020-01-02 15:05:55 -0800
committerAshkan Kiani <ashkan.k.kiani@gmail.com>2020-01-02 15:05:55 -0800
commitcf7310dbe6529baaed1ca48345ba96e9c266dabc (patch)
treee7ea42459c14b1f2cf25f527c5afe70a0ac809a0
parentAdd "set" keys to jump to a percentage. (diff)
Bugfix for no matches and trim extra width.color-editor
-rw-r--r--lua/colorizer.lua7
1 files changed, 4 insertions, 3 deletions
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?