feat: Add option to disable auto-adding current file when opening new chat (#2764)

Co-authored-by: yetone <1206493+yetone@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
Copilot
2025-10-13 11:34:44 +08:00
committed by GitHub
parent f092bb3ec0
commit 60cb63cdd2
4 changed files with 14 additions and 7 deletions

View File

@@ -1672,15 +1672,18 @@ function Sidebar:initialize()
local buf_ft = api.nvim_get_option_value("filetype", { buf = self.code.bufnr })
if vim.list_contains(Config.selector.exclude_auto_select, buf_ft) then return self end
local buf_path = api.nvim_buf_get_name(self.code.bufnr)
-- if the filepath is outside of the current working directory then we want the absolute path
local filepath = Utils.file.is_in_project(buf_path) and Utils.relative_path(buf_path) or buf_path
Utils.debug("Sidebar:initialize adding buffer to file selector", buf_path)
self.file_selector:reset()
local stat = vim.uv.fs_stat(filepath)
if stat == nil or stat.type == "file" then self.file_selector:add_selected_file(filepath) end
-- Only auto-add current file if configured to do so
if Config.behaviour.auto_add_current_file then
local buf_path = api.nvim_buf_get_name(self.code.bufnr)
-- if the filepath is outside of the current working directory then we want the absolute path
local filepath = Utils.file.is_in_project(buf_path) and Utils.relative_path(buf_path) or buf_path
Utils.debug("Sidebar:initialize adding buffer to file selector", buf_path)
local stat = vim.uv.fs_stat(filepath)
if stat == nil or stat.type == "file" then self.file_selector:add_selected_file(filepath) end
end
self:reload_chat_history()