@@ -69,15 +69,16 @@ function Agenda:tags_todo()
6969 return self :tags ({ todo_only = true })
7070end
7171
72- --- @return number | nil window id
72+ --- @return number | nil , number window id nand buffer id
7373function Agenda :open_window ()
7474 -- if an agenda window is already open, return it
7575 for _ , win in ipairs (vim .api .nvim_list_wins ()) do
76+ local buf = vim .api .nvim_win_get_buf (win )
7677 local ft = vim .api .nvim_get_option_value (' filetype' , {
77- buf = vim . api . nvim_win_get_buf ( win ) ,
78+ buf = buf ,
7879 })
7980 if ft == ' orgagenda' then
80- return win
81+ return win , buf
8182 end
8283 end
8384
@@ -87,7 +88,7 @@ function Agenda:open_window()
8788 vim .cmd ([[ setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap nospell]] )
8889 vim .w .org_window_pos = vim .fn .win_screenpos (0 )
8990 config :setup_mappings (' agenda' )
90- return vim .fn .win_getid ()
91+ return vim .fn .win_getid (), vim . fn . bufnr ()
9192end
9293
9394function Agenda :prompt ()
@@ -147,8 +148,7 @@ function Agenda:_render(skip_rebuild)
147148 utils .concat (self .highlights , view .highlights )
148149 end
149150 end
150- local win = self :open_window ()
151- vim .cmd (vim .fn .win_id2win (win ) .. ' wincmd w' )
151+ local win , bufnr = self :open_window ()
152152 if vim .w .org_window_split_mode == ' horizontal' then
153153 local win_height = math.max (math.min (34 , # self .content ), config .org_agenda_min_height )
154154 if vim .w .org_window_pos and vim .deep_equal (vim .fn .win_screenpos (0 ), vim .w .org_window_pos ) then
@@ -161,14 +161,14 @@ function Agenda:_render(skip_rebuild)
161161 local lines = vim .tbl_map (function (item )
162162 return item .line_content
163163 end , self .content )
164- vim .bo .modifiable = true
165- vim .api .nvim_buf_set_lines (0 , 0 , - 1 , true , lines )
166- vim .bo .modifiable = false
167- vim .bo .modified = false
168- colors .highlight (self .highlights , true )
164+ vim .bo [ bufnr ] .modifiable = true
165+ vim .api .nvim_buf_set_lines (bufnr , 0 , - 1 , true , lines )
166+ vim .bo [ bufnr ] .modifiable = false
167+ vim .bo [ bufnr ] .modified = false
168+ colors .highlight (self .highlights , true , bufnr )
169169 vim .tbl_map (function (item )
170170 if item .highlights then
171- return colors .highlight (item .highlights )
171+ return colors .highlight (item .highlights , false , bufnr )
172172 end
173173 end , self .content )
174174 if not skip_rebuild then
0 commit comments