Skip to content

Commit 2719a43

Browse files
committed
fix(quick_chat): improve patch block parsing and application logic
- Simplified whitespace normalization and Lua pattern handling. - Improved parsing logic for SEARCH/REPLACE blocks with better error handling.
1 parent f3ee5e9 commit 2719a43

File tree

2 files changed

+199
-121
lines changed

2 files changed

+199
-121
lines changed

lua/opencode/context/quick_chat_context.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ local function format_buffer(buf, lang)
105105
return string.format('[FILE]: %s\n\n```%s\n%s\n```', rel_path, lang, content)
106106
end
107107

108+
---@return integer|nil, integer|nil
109+
function M.get_current_buf()
110+
local buf = vim.api.nvim_get_current_buf()
111+
local win = vim.api.nvim_get_current_win()
112+
return buf, win
113+
end
114+
108115
--- Formats context as plain text for LLM consumption (used by quick chat)
109116
--- Unlike ChatContext, this outputs human-readable text instead of structured JSON
110117
---@param prompt string The user's instruction/prompt
@@ -113,7 +120,7 @@ end
113120
M.format_message = Promise.async(function(prompt, opts)
114121
opts = opts or {}
115122
local context_config = opts.context_config
116-
local buf, win = base_context.get_current_buf()
123+
local buf, win = M.get_current_buf()
117124

118125
if not buf or not win then
119126
return {

0 commit comments

Comments
 (0)