Skip to content

Commit a9ec0eb

Browse files
committed
refactor
1 parent 768ee28 commit a9ec0eb

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

lua/codecompanion/interactions/chat/tools/builtin/insert_edit_into_file/constants.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
---Constants for the insert_edit_into_file tool
2-
31
local config = require("codecompanion.config")
42

53
local M = {}

lua/codecompanion/interactions/chat/tools/builtin/insert_edit_into_file/init.lua

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,9 @@ file boundaries (start/end), and complete file overwrites.
4343
--]]
4444

4545
local Path = require("plenary.path")
46-
47-
local Approvals = require("codecompanion.interactions.chat.tools.approvals")
48-
local Constants = require("codecompanion.interactions.chat.tools.builtin.insert_edit_into_file.constants")
46+
local approvals = require("codecompanion.interactions.chat.tools.approvals")
4947
local config = require("codecompanion.config")
48+
local constants = require("codecompanion.interactions.chat.tools.builtin.insert_edit_into_file.constants")
5049
local helpers = require("codecompanion.interactions.chat.helpers")
5150
local match_selector = require("codecompanion.interactions.chat.tools.builtin.insert_edit_into_file.match_selector")
5251
local strategies = require("codecompanion.interactions.chat.tools.builtin.insert_edit_into_file.strategies")
@@ -683,14 +682,14 @@ local function edit_file(action, chat_bufnr, output_handler, opts)
683682
end
684683
end
685684

686-
if #current_content > Constants.LIMITS.FILE_SIZE_MAX then
685+
if #current_content > constants.LIMITS.FILE_SIZE_MAX then
687686
return output_handler(
688687
mk_response(
689688
"error",
690689
fmt(
691690
"Error: File too large (%d bytes). Maximum supported size is %d bytes.",
692691
#current_content,
693-
Constants.LIMITS.FILE_SIZE_MAX
692+
constants.LIMITS.FILE_SIZE_MAX
694693
)
695694
)
696695
)
@@ -740,7 +739,7 @@ local function edit_file(action, chat_bufnr, output_handler, opts)
740739
end
741740

742741
-- If the tool has been approved then skip showing the diff
743-
if Approvals:is_approved(chat_bufnr, { tool_name = "insert_edit_into_file" }) then
742+
if approvals:is_approved(chat_bufnr, { tool_name = "insert_edit_into_file" }) then
744743
return output_handler(
745744
mk_response("success", fmt("Edited `%s` file%s", action.filepath, extract_explanation(action)))
746745
)
@@ -861,7 +860,7 @@ local function edit_buffer(bufnr, chat_bufnr, action, output_handler, opts)
861860
local success_msg = fmt("Edited `%s` buffer%s", display_name, extract_explanation(action))
862861

863862
-- If the tool has been approved then skip showing the diff
864-
if Approvals:is_approved(chat_bufnr, { tool_name = "insert_edit_into_file" }) then
863+
if approvals:is_approved(chat_bufnr, { tool_name = "insert_edit_into_file" }) then
865864
api.nvim_buf_call(bufnr, function()
866865
vim.cmd("silent write")
867866
end)

0 commit comments

Comments
 (0)