File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,9 +49,39 @@ function M.setup_autocmds(windows)
4949 })
5050
5151 vim .api .nvim_create_autocmd (' DirChanged' , {
52+ pattern = { ' global' , ' tabpage' },
5253 group = group ,
5354 callback = function (event )
5455 local state = require (' opencode.state' )
56+ if state .current_cwd == event .file then
57+ return
58+ end
59+
60+ if event .match == ' tabpage' then
61+ local windows = state .windows
62+ if not windows or not windows .output_win or not vim .api .nvim_win_is_valid (windows .output_win ) then
63+ return
64+ end
65+
66+ local ok , opencode_tab = pcall (vim .api .nvim_win_get_tabpage , windows .output_win )
67+ if not ok then
68+ return
69+ end
70+
71+ local changed_tab = vim .api .nvim_get_current_tabpage ()
72+ local changed_window = event .data and event .data .changed_window
73+ if changed_window and vim .api .nvim_win_is_valid (changed_window ) then
74+ local win_ok , win_tab = pcall (vim .api .nvim_win_get_tabpage , changed_window )
75+ if win_ok then
76+ changed_tab = win_tab
77+ end
78+ end
79+
80+ if changed_tab ~= opencode_tab then
81+ return
82+ end
83+ end
84+
5585 state .current_cwd = event .file
5686 local core = require (' opencode.core' )
5787 core .handle_directory_change ()
You can’t perform that action at this time.
0 commit comments