Skip to content

Commit 2192327

Browse files
committed
fix(cmp, blink): Non-existing peview no longer causes error with completion
Closes #320
1 parent 7a7d3ed commit 2192327

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lua/blink-markview.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function source:get_completions(ctx, callback)
4444

4545
for key, item in pairs(items) do
4646
if vim.list_contains({ "enable", "wrap", "default" }, key) == false then
47-
local label = "[!" .. key .. "]" .. " » " .. item.preview;
47+
local label = "[!" .. key .. "]" .. " » " .. (item.preview or "");
4848
local result = key;
4949

5050
if string.match(after, "^%]") == nil then
@@ -67,7 +67,7 @@ function source:get_completions(ctx, callback)
6767

6868
documentation = {
6969
kind = "plaintext",
70-
value = string.format("▌ %s\n▌ Block quote description.", item.preview);
70+
value = string.format("▌ %s\n▌ Block quote description.", item.preview or "");
7171
}
7272
});
7373
end
@@ -77,7 +77,7 @@ function source:get_completions(ctx, callback)
7777

7878
for key, item in pairs(items) do
7979
if vim.list_contains({ "enable", "checked", "unchecked" }, key) == false then
80-
local label = "[" .. key .. "]" .. " » " .. item.text .. " ";
80+
local label = "[" .. key .. "]" .. " » " .. (item.text or "") .. " ";
8181
local result = key;
8282

8383
if string.match(after, "^%]") == nil then
@@ -100,7 +100,7 @@ function source:get_completions(ctx, callback)
100100

101101
documentation = {
102102
kind = "plaintext",
103-
value = string.format("◇ List item,\n %s Checkbox with\n some text.", item.text);
103+
value = string.format("◇ List item,\n %s Checkbox with\n some text.", item.text or "");
104104
}
105105
});
106106
end

lua/cmp-markview.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function source:complete(params, callback)
5454
local label = "[!" .. key;
5555
local desc = {
5656
string.format("▌ %s",
57-
item.preview
57+
item.preview or ""
5858
),
5959
"▌ Block quote description."
6060
};
@@ -64,7 +64,7 @@ function source:complete(params, callback)
6464
end
6565

6666
local result = label;
67-
label = label .. " » " .. item.preview;
67+
label = label .. " » " .. (item.preview or "");
6868

6969
table.insert(comp, {
7070
label = label,
@@ -85,7 +85,7 @@ function source:complete(params, callback)
8585
local desc = {
8686
"◇ List item,",
8787
string.format(" %s Checkbox with",
88-
item.text
88+
item.text or ""
8989
),
9090
" some text."
9191
};
@@ -95,7 +95,7 @@ function source:complete(params, callback)
9595
end
9696

9797
local result = label;
98-
label = label .. " » " .. item.text;
98+
label = label .. " » " .. (item.text or "");
9999

100100
table.insert(comp, {
101101
label = label,

0 commit comments

Comments
 (0)