chore: fix types (#173)

This commit is contained in:
yetone 2024-08-23 18:33:49 +08:00 committed by GitHub
parent 7d4be712f0
commit 25f8175662
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 1 deletions

View File

@ -1165,6 +1165,10 @@ Available commands:
start_line = tonumber(start_line)
---@cast end_line integer
end_line = tonumber(end_line)
if end_line == nil then
Utils.error("Invalid end line number", { once = true, title = "Avante" })
return
end
selected_code_content_with_line_numbers = prepend_line_number(
table.concat(api.nvim_buf_get_lines(self.code.bufnr, start_line - 1, end_line, false), "\n"),
start_line

View File

@ -80,7 +80,11 @@ function M.get_visual_selection_and_range()
-- Extract partial content of the last line
-- lines[#lines] = string.sub(lines[#lines], 1, end_col)
-- Concatenate all lines in the selection into a string
content = table.concat(lines, "\n")
if type(lines) == "table" then
content = table.concat(lines, "\n")
else
content = lines
end
end
if not content then
return nil
@ -143,10 +147,13 @@ function M.notify(msg, opts)
"\n"
)
end
---@diagnostic disable-next-line: undefined-field
if opts.stacktrace then
---@diagnostic disable-next-line: undefined-field
msg = msg .. M.pretty_trace({ level = opts.stacklevel or 2 })
end
local lang = opts.lang or "markdown"
---@diagnostic disable-next-line: undefined-field
local n = opts.once and vim.notify_once or vim.notify
n(msg, opts.level or vim.log.levels.INFO, {
on_open = function(win)