Skip to content

Commit ac81c4c

Browse files
committed
refactor(quick_chat): extract search/replace and spinner into separate modules
Move CursorSpinner class and SEARCH/REPLACE parsing logic into dedicated modules under quick_chat/. Add context-aware instruction generation and improve error feedback for replacement operations. >
1 parent 9865b88 commit ac81c4c

File tree

4 files changed

+614
-422
lines changed

4 files changed

+614
-422
lines changed

lua/opencode/context/base.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,27 @@ function ContextInstance:get_current_selection()
375375
}
376376
end
377377

378+
ContextInstance.has = Promise.async(function(self, context_type)
379+
if context_type == 'file' then
380+
return self:get_mentioned_files() and #self:get_mentioned_files() > 0
381+
elseif context_type == 'selection' then
382+
return self:get_selections() and #self:get_selections() > 0
383+
elseif context_type == 'subagent' then
384+
return self:get_mentioned_subagents() and #self:get_mentioned_subagents() > 0
385+
elseif context_type == 'diagnostics' then
386+
return self.context.linter_errors and #self.context.linter_errors > 0
387+
elseif context_type == 'git_diff' then
388+
local git_diff = Promise.await(self:get_git_diff())
389+
return git_diff ~= nil
390+
elseif context_type == 'current_file' then
391+
return self.context.current_file ~= nil
392+
elseif context_type == 'cursor_data' then
393+
return self.context.cursor_data ~= nil
394+
end
395+
396+
return false
397+
end)
398+
378399
function ContextInstance:get_selections()
379400
if not self:is_context_enabled('selection') then
380401
return {}

0 commit comments

Comments
 (0)