@@ -282,45 +282,54 @@ local function c_tabs()
282282 return table.concat (tabs , " " )
283283end
284284
285- -- Determine whether a window is a regular editing window (not floating, not special buffer).
286- local function is_editing_win (winid )
285+ -- Resolve the buffer to display in the statusline.
286+ -- When the active window is a floating/non-editing window (e.g. Sidekick),
287+ -- falls back to a visible non-floating window with a regular file buffer.
288+ local function statusline_bufnr (winid )
289+ local bufnr = vim .api .nvim_win_get_buf (winid )
287290 local win_config = vim .api .nvim_win_get_config (winid )
288- if win_config .relative ~= " " then
289- return false
291+
292+ if win_config .relative == " " and vim .bo [bufnr ].buftype == " " then
293+ return bufnr
290294 end
291- local bufnr = vim .api .nvim_win_get_buf (winid )
292- return vim .bo [bufnr ].buftype == " "
295+
296+ for _ , w in ipairs (vim .api .nvim_list_wins ()) do
297+ if w ~= winid then
298+ local cfg = vim .api .nvim_win_get_config (w )
299+ if cfg .relative == " " then
300+ local b = vim .api .nvim_win_get_buf (w )
301+ if vim .bo [b ].buftype == " " then
302+ return b
303+ end
304+ end
305+ end
306+ end
307+
308+ return bufnr
293309end
294310
295311-- Construct the statusline (default)
296312function _G .statusline ()
297313 local winid = vim .g .statusline_winid or vim .api .nvim_get_current_win ()
314+ local bufnr = statusline_bufnr (winid )
298315 local hl = " %#StatusLine#"
299316
300317 local components = {
301318 hl ,
302319 c_mode (),
303320 c_spinner (),
304321 c_project (),
322+ c_filename (bufnr ),
323+ c_bookmark (),
324+ " %=" ,
325+ " %=" ,
326+ c_lsp_diagnostics (bufnr ),
327+ c_git_status (bufnr ),
328+ c_git_branch (bufnr ),
329+ c_cursor_position (),
330+ c_tabs (),
305331 }
306332
307- if is_editing_win (winid ) then
308- local bufnr = vim .api .nvim_win_get_buf (winid )
309- components [# components + 1 ] = c_filename (bufnr )
310- components [# components + 1 ] = c_bookmark ()
311- components [# components + 1 ] = " %="
312- components [# components + 1 ] = " %="
313- components [# components + 1 ] = c_lsp_diagnostics (bufnr )
314- components [# components + 1 ] = c_git_status (bufnr )
315- components [# components + 1 ] = c_git_branch (bufnr )
316- else
317- components [# components + 1 ] = " %="
318- components [# components + 1 ] = " %="
319- end
320-
321- components [# components + 1 ] = c_cursor_position ()
322- components [# components + 1 ] = c_tabs ()
323-
324333 local filtered_components = {}
325334 for _ , component in ipairs (components ) do
326335 if component ~= " " then
0 commit comments