@@ -11,6 +11,18 @@ endfunction
1111
1212let s: sync = {}
1313
14+ function ! s: sync_winid () abort dict
15+ let helper = self .helper
16+ if win_id2tabwin (helper.winid) != [0 , 0 ]
17+ return helper.winid
18+ endif
19+ " Original window has disappeared
20+ let winids = win_findbuf (helper.bufnr )
21+ let helper.winid = len (winids) is # 0 ? -1 : winids[0 ]
22+ return helper.winid
23+ endfunction
24+ let s: sync .winid = funcref (' s:sync_winid' )
25+
1426function ! s: sync_echo (message, ... ) abort dict
1527 let hl = a: 0 ? a: 1 : ' None'
1628 try
@@ -73,14 +85,22 @@ let s:sync.get_selected_nodes = funcref('s:sync_get_selected_nodes')
7385function ! s: sync_get_cursor () abort dict
7486 let helper = self .helper
7587 let fern = helper.fern
76- return s: WindowCursor .get_cursor (helper.winid)
88+ let winid = self .winid ()
89+ if winid is # -1
90+ return [0 , 0 ]
91+ endif
92+ return s: WindowCursor .get_cursor (winid)
7793endfunction
7894let s: sync .get_cursor = funcref (' s:sync_get_cursor' )
7995
8096function ! s: sync_set_cursor (cursor ) abort dict
8197 let helper = self .helper
8298 let fern = helper.fern
83- call s: WindowCursor .set_cursor (helper.winid, a: cursor )
99+ let winid = self .winid ()
100+ if winid is # -1
101+ return
102+ endif
103+ call s: WindowCursor .set_cursor (winid, a: cursor )
84104 call setbufvar (helper.bufnr , ' fern_cursor' , a: cursor )
85105endfunction
86106let s: sync .set_cursor = funcref (' s:sync_set_cursor' )
0 commit comments