Skip to content

Commit a04610d

Browse files
authored
fix: Prevent block_locator from ignoring newlines
block_locator was trimming empty lines from the beginning and end of files. This is more impactful when trying to append to a file that ends in a newline, which would include any text file adhering to the POSIX standard (ending in a newline). Sometimes LLMs include the trailing newline in the search block, which causes the bound check to short-circuit in SearchEngine:_evaluate_position().
1 parent 424e8c9 commit a04610d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lua/mcphub/native/neovim/files/edit_file/block_locator.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ end
2828
---@param file_content string Content of the target file
2929
---@return LocatedBlock[] located_blocks Blocks with location information
3030
function BlockLocator:locate_all_blocks(parsed_blocks, file_content)
31-
local file_lines = vim.split(file_content, "\n", { plain = true, trimempty = true })
31+
local file_lines = vim.split(file_content, "\n", { plain = true, trimempty = false })
3232
local located_blocks = {}
3333
for _, parsed_block in ipairs(parsed_blocks) do
3434
if vim.trim(parsed_block.search_content) == "" then

0 commit comments

Comments
 (0)