|
218 | 218 |
|
219 | 219 | M.blines = function(opts) |
220 | 220 | opts = config.normalize_opts(opts, "blines") |
| 221 | + -- TODO: remove this guard |
| 222 | + if not opts then return end |
221 | 223 | opts.current_buffer_only = true |
222 | 224 | if utils.mode_is_visual() then |
223 | 225 | local _, sel = utils.get_visual_selection() |
| 226 | + if not sel then return end |
224 | 227 | opts.start_line = opts.start_line or sel.start.line |
225 | 228 | opts.end_line = opts.end_line or sel["end"].line |
226 | 229 | end |
@@ -255,6 +258,7 @@ M.buffer_lines = function(opts) |
255 | 258 | local bnames = {} |
256 | 259 | local longest_bname = 0 |
257 | 260 | for _, b in ipairs(buffers) do |
| 261 | + ---@type string |
258 | 262 | local bname = utils.nvim_buf_get_name(b) |
259 | 263 | if not bname:match("^%[") then |
260 | 264 | bname = path.shorten(vim.fn.fnamemodify(bname, ":~:.")) |
@@ -606,6 +610,7 @@ M.spellcheck = function(opts) |
606 | 610 |
|
607 | 611 | if utils.mode_is_visual() then |
608 | 612 | local _, sel = utils.get_visual_selection() |
| 613 | + if not sel then return end |
609 | 614 | opts.start_line = opts.start_line or sel.start.line |
610 | 615 | opts.end_line = opts.end_line or sel["end"].line |
611 | 616 | end |
@@ -655,7 +660,7 @@ M.spellcheck = function(opts) |
655 | 660 | return s:gsub("^" .. word_separator .. "+", ""):gsub(word_separator .. "+$", "") |
656 | 661 | end |
657 | 662 | from, to = string.find(line, "%w+", from) |
658 | | - local word = from and string.sub(line, from, to) |
| 663 | + local word = from and string.sub(line, from, to) or "" |
659 | 664 | local prefix = from and string.sub(line, from - 1, from - 1) or "" |
660 | 665 | local postfix = to and string.sub(line, to + 1, to + 1) or "" |
661 | 666 | local valid_word = word |
|
0 commit comments