@@ -187,17 +187,21 @@ local function save(name, opts, target_tabpage)
187187 table.insert (data .buffers , buf )
188188 end
189189 end
190+ local current_tabpage = vim .api .nvim_get_current_tabpage ()
190191 local tabpages = target_tabpage and { target_tabpage } or vim .api .nvim_list_tabpages ()
191192 for _ , tabpage in ipairs (tabpages ) do
193+ vim .api .nvim_set_current_tabpage (tabpage )
192194 local tab = {}
193195 local tabnr = vim .api .nvim_tabpage_get_number (tabpage )
194196 if target_tabpage or vim .fn .haslocaldir (- 1 , tabnr ) == 1 then
195197 tab .cwd = vim .fn .getcwd (- 1 , tabnr )
196198 end
199+ tab .options = util .save_tab_options (tabpage )
197200 table.insert (data .tabs , tab )
198201 local winlayout = vim .fn .winlayout (tabnr )
199202 tab .wins = layout .add_win_info_to_layout (tabnr , winlayout )
200203 end
204+ vim .api .nvim_set_current_tabpage (current_tabpage )
201205
202206 for ext_name , ext_config in pairs (config .extensions ) do
203207 local ext = util .get_extension (ext_name )
@@ -461,6 +465,9 @@ M.load = function(name, opts)
461465 if win then
462466 curwin = win
463467 end
468+ if tab .options then
469+ util .restore_tab_options (tab .options )
470+ end
464471 end
465472 -- This can be nil if we saved a session in a window with an unsupported buffer
466473 if curwin then
@@ -482,10 +489,6 @@ M.load = function(name, opts)
482489 end
483490 end
484491
485- -- We re-apply the options because sometimes the cmdheight gets messed up for some reason
486- for k , v in pairs (data .global .options ) do
487- vim .o [k ] = v
488- end
489492 current_session = nil
490493 if opts .reset then
491494 tab_sessions = {}
0 commit comments