feat(file-manager): sync the working directory by default
The panel and the shell now share their directory out of the box; whoever wants the previous independence sets sync_cwd no. The request is only written once the shell has published its directory, since that file is what proves its integration hook will read the request: a shell without shell integration still gets the cd typed into the terminal instead of losing the change.
This commit is contained in:
7 files changed
+61
-16
No files matched your search
@@ -42,6 +42,14 @@ func new_shell_sync_from_env(enabled bool) *shell_sync {
|
||||
func (s *shell_sync) shell_cwd_path() string { return filepath.Join(s.dir, s.window_id) }
|
||||
func (s *shell_sync) request_path() string { return s.shell_cwd_path() + ".set" }
|
||||
|
||||
// shell_has_hook reports whether the shell has published its working directory
|
||||
// at least once, which only the integration hook does. Without it nothing would
|
||||
// consume the request, so the panel has to type the change into the shell.
|
||||
func (s *shell_sync) shell_has_hook() bool {
|
||||
_, err := os.Stat(s.shell_cwd_path())
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// shell_cwd returns the working directory last published by the shell. An empty
|
||||
// or relative path, or one that no longer exists, is treated as unknown rather
|
||||
// than followed, as the shell may be between two writes.
|
||||
|
||||
Reference in new issue
Block a user