Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lua/CopilotChat/ui/chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,8 @@ function Chat:render()
if self.config.auto_fold and self:visible() then
if message.role ~= constants.ROLE.ASSISTANT and message.section and i < #self.messages then
vim.api.nvim_win_call(self.winnr, function()
if vim.fn.foldclosed(message.section.start_line) == -1 then
local fold_level = vim.fn.foldlevel(message.section.start_line)
if fold_level > 0 and vim.fn.foldclosed(message.section.start_line) == -1 then
vim.api.nvim_cmd({ cmd = 'foldclose', range = { message.section.start_line } }, {})
end
end)
Expand Down
9 changes: 2 additions & 7 deletions lua/CopilotChat/utils/files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ M.glob = async.wrap(function(path, opts, callback)
end

table.insert(cmd, '--files')
table.insert(cmd, path)

vim.system(cmd, { text = true }, function(result)
vim.system(cmd, { cwd = path, text = true }, function(result)
local files = {}
if result and result.code == 0 and result.stdout ~= '' then
files = filter_files(vim.split(result.stdout, '\n'), opts.max_count)
Expand Down Expand Up @@ -179,8 +178,6 @@ M.grep = async.wrap(function(path, opts, callback)
table.insert(cmd, '-e')
table.insert(cmd, "'" .. opts.pattern .. "'")
end

table.insert(cmd, path)
elseif vim.fn.executable('grep') == 1 then
table.insert(cmd, 'grep')
table.insert(cmd, '-rli')
Expand All @@ -189,16 +186,14 @@ M.grep = async.wrap(function(path, opts, callback)
table.insert(cmd, '-e')
table.insert(cmd, "'" .. opts.pattern .. "'")
end

table.insert(cmd, path)
end

if M.empty(cmd) then
error('No executable found for grep')
return
end

vim.system(cmd, { text = true }, function(result)
vim.system(cmd, { cwd = path, text = true }, function(result)
local files = {}
if result and result.code == 0 and result.stdout ~= '' then
files = filter_files(vim.split(result.stdout, '\n'), opts.max_count)
Expand Down
Loading