Skip to content

Commit dd10fdd

Browse files
committed
feat(bridge): use global cd in set_cwd so terminals follow worktree
1 parent 1eb19bc commit dd10fdd

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

lua/neocrush/bridge.lua

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,10 @@ end
206206

207207
---Change Neovim's working directory to path, e.g. when Crush switches
208208
---the active worktree so the editor follows the agent into the new
209-
---tree. Uses tab-local :tcd so a switch only affects the current tab
210-
---(leaving other tabs' cwd intact), falling back to global :cd if tcd
211-
---is unavailable. Best-effort: never raises, and silently ignores a
212-
---missing/empty path or a directory that no longer exists.
209+
---tree. Uses global :cd so the change is instance-wide: new buffers,
210+
---:terminal jobs, and floating terminals all spawn in the worktree.
211+
---Best-effort: never raises, and silently ignores a missing/empty path
212+
---or a directory that no longer exists.
213213
---@param path string absolute directory path
214214
function M.set_cwd(path)
215215
if path == nil or path == '' then
@@ -221,10 +221,7 @@ function M.set_cwd(path)
221221
return
222222
end
223223
-- Quote against spaces/specials in the path.
224-
local quoted = vim.fn.fnameescape(dir)
225-
if not pcall(vim.cmd, 'tcd ' .. quoted) then
226-
pcall(vim.cmd, 'cd ' .. quoted)
227-
end
224+
pcall(vim.cmd, 'cd ' .. vim.fn.fnameescape(dir))
228225
end)
229226
end
230227

0 commit comments

Comments
 (0)