Add --add/--new to control CLI behaviour (#9202)
When neither is specified, if you open a directory you get a new workspace, otherwise files are added to your existing workspace. With --new files are always opened in a new workspace With --add directories are always added to an existing workspace Fixes #9076 Fixes #4861 Fixes #5370 Release Notes: - Added `-n/--new` and `-a/--add` to the zed CLI. When neither is specified, if you open a directory you get a new workspace, otherwise files are added to your existing workspace. With `--new` files are always opened in a new workspace, with `--add` directories are always added to an existing workspace. ([#9076](https://github.com/zed-industries/zed/issues/9096), [#4861](https://github.com/zed-industries/zed/issues/4861), [#5370](https://github.com/zed-industries/zed/issues/5370)).
This commit is contained in:
parent
89c67fb1ab
commit
05dfe96f0c
9 changed files with 369 additions and 103 deletions
|
@ -1145,18 +1145,24 @@ impl Project {
|
|||
.map(|worktree| worktree.read(cx).id())
|
||||
}
|
||||
|
||||
pub fn contains_paths(&self, paths: &[PathBuf], cx: &AppContext) -> bool {
|
||||
paths.iter().all(|path| self.contains_path(path, cx))
|
||||
pub fn visibility_for_paths(&self, paths: &[PathBuf], cx: &AppContext) -> Option<bool> {
|
||||
paths
|
||||
.iter()
|
||||
.map(|path| self.visibility_for_path(path, cx))
|
||||
.max()
|
||||
.flatten()
|
||||
}
|
||||
|
||||
pub fn contains_path(&self, path: &Path, cx: &AppContext) -> bool {
|
||||
for worktree in self.worktrees() {
|
||||
let worktree = worktree.read(cx).as_local();
|
||||
if worktree.map_or(false, |w| w.contains_abs_path(path)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
pub fn visibility_for_path(&self, path: &Path, cx: &AppContext) -> Option<bool> {
|
||||
self.worktrees()
|
||||
.filter_map(|worktree| {
|
||||
let worktree = worktree.read(cx);
|
||||
worktree
|
||||
.as_local()?
|
||||
.contains_abs_path(path)
|
||||
.then(|| worktree.is_visible())
|
||||
})
|
||||
.max()
|
||||
}
|
||||
|
||||
pub fn create_entry(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue