fix(ci): lua style (#946)
This commit is contained in:
parent
eb1bc657a1
commit
1516ce093a
@ -33,37 +33,37 @@ function FileSelector:reset()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function FileSelector:add_selected_file(filepath)
|
function FileSelector:add_selected_file(filepath)
|
||||||
local uniform_path = Utils.uniform_path(filepath)
|
local uniform_path = Utils.uniform_path(filepath)
|
||||||
-- Avoid duplicates
|
-- Avoid duplicates
|
||||||
if not vim.tbl_contains(self.selected_filepaths, uniform_path) then
|
if not vim.tbl_contains(self.selected_filepaths, uniform_path) then
|
||||||
table.insert(self.selected_filepaths, uniform_path)
|
table.insert(self.selected_filepaths, uniform_path)
|
||||||
self:emit("update")
|
self:emit("update")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function FileSelector:add_current_buffer()
|
function FileSelector:add_current_buffer()
|
||||||
local current_buf = vim.api.nvim_get_current_buf()
|
local current_buf = vim.api.nvim_get_current_buf()
|
||||||
local filepath = vim.api.nvim_buf_get_name(current_buf)
|
local filepath = vim.api.nvim_buf_get_name(current_buf)
|
||||||
|
|
||||||
-- Only process if it's a real file buffer
|
-- Only process if it's a real file buffer
|
||||||
if filepath and filepath ~= "" and not vim.startswith(filepath, "avante://") then
|
if filepath and filepath ~= "" and not vim.startswith(filepath, "avante://") then
|
||||||
local relative_path = require("avante.utils").relative_path(filepath)
|
local relative_path = require("avante.utils").relative_path(filepath)
|
||||||
|
|
||||||
-- Check if file is already in list
|
-- Check if file is already in list
|
||||||
for i, path in ipairs(self.selected_filepaths) do
|
for i, path in ipairs(self.selected_filepaths) do
|
||||||
if path == relative_path then
|
if path == relative_path then
|
||||||
-- Remove if found
|
-- Remove if found
|
||||||
table.remove(self.selected_filepaths, i)
|
table.remove(self.selected_filepaths, i)
|
||||||
self:emit("update")
|
self:emit("update")
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Add if not found
|
|
||||||
self:add_selected_file(relative_path)
|
|
||||||
return true
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return false
|
|
||||||
|
-- Add if not found
|
||||||
|
self:add_selected_file(relative_path)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function FileSelector:on(event, callback)
|
function FileSelector:on(event, callback)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user