Skip to content

Commit f6f5f77

Browse files
committed
fix(context): preserve selections when switching files in chat context
Previously, selections were cleared when switching files, resulting in a loss of context for the user. This change ensures selection state is maintained across file switches, improving UX continuity. This should improve #248
1 parent 954123c commit f6f5f77

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

lua/opencode/context/chat_context.lua

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,6 @@ function M.load()
379379
local should_update_file, is_different_file = M.should_update_current_file(current_file)
380380

381381
if should_update_file then
382-
if is_different_file then
383-
M.context.selections = {}
384-
end
385-
386382
M.context.current_file = current_file
387383
if M.context.current_file then
388384
M.context.current_file.sent_at = nil
@@ -399,8 +395,7 @@ function M.load()
399395
if current_selection then
400396
local selection_file = base_context.get_current_file_for_selection(buf)
401397
if selection_file then
402-
local selection =
403-
base_context.new_selection(selection_file, current_selection.text, current_selection.lines)
398+
local selection = base_context.new_selection(selection_file, current_selection.text, current_selection.lines)
404399
M.add_selection(selection)
405400
end
406401
end

0 commit comments

Comments
 (0)