Skip to content

[audit] statusline current_file() uses global cwd — lcd window-local changes not reflected #122

Description

@stanfish06

What

current_file() in the statusline computes the display path using vim.uv.cwd(), which returns the OS-level process cwd — it ignores any :lcd window-local directory override.

Where

lua/config/statusline.lua line 256:

local root_path = vim.uv.cwd() or ""

Why it matters

init.lua explicitly documents :lcd as a useful feature:

"lcd allows you to set root directory for current window, which might be useful in some cases"

But after :lcd /some/subdir, the statusline still shows paths relative to the original global cwd rather than the window-local one. The path trimming logic on lines 258–268 (home_path:find(root_dir)) can silently produce wrong-looking paths or fall back to showing the full ~-prefixed path whenever the lcd doesn't match the global cwd's trailing component.

Recommended action

Replace vim.uv.cwd() with vim.fn.getcwd(0, 0), which returns the local cwd for the current window (falls back to global cwd if no lcd is set):

-local root_path = vim.uv.cwd() or ""
+local root_path = vim.fn.getcwd(0, 0)

vim.fn.getcwd() always returns a string so the or "" fallback is not needed. This is a one-liner change but the right behaviour depends on whether you want per-window relative paths — hence the issue rather than a direct PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions