Skip to content

Commit 3798e7f

Browse files
committed
fix(context): prevent adding visual selection when selection context is disabled
Add a guard in M.add_visual_selection to check M.is_context_enabled('selection'). When the selection context is disabled, notify the user with a warning and return false to avoid performing selection operations when the feature is turned off. This should close #386
1 parent fb34b46 commit 3798e7f

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

lua/opencode/context.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ end
132132
---@param range? OpencodeSelectionRange
133133
---@return boolean success Whether a selection was successfully added
134134
function M.add_visual_selection(range)
135+
if not M.is_context_enabled('selection') then
136+
vim.notify('Selection context is disabled. Enable it to add visual selections.', vim.log.levels.WARN)
137+
return false
138+
end
139+
135140
local buf = vim.api.nvim_get_current_buf()
136141

137142
if not util.is_buf_a_file(buf) then

0 commit comments

Comments
 (0)