Extract project_panel
into its own crate
This commit is contained in:
parent
499616d769
commit
d04a11405c
6 changed files with 39 additions and 17 deletions
13
Cargo.lock
generated
13
Cargo.lock
generated
|
@ -3733,6 +3733,18 @@ dependencies = [
|
||||||
"util",
|
"util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "project_panel"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"gpui",
|
||||||
|
"postage",
|
||||||
|
"project",
|
||||||
|
"serde_json 1.0.64",
|
||||||
|
"theme",
|
||||||
|
"workspace",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "prost"
|
name = "prost"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
|
@ -6113,6 +6125,7 @@ dependencies = [
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"postage",
|
"postage",
|
||||||
"project",
|
"project",
|
||||||
|
"project_panel",
|
||||||
"rand 0.8.3",
|
"rand 0.8.3",
|
||||||
"rpc",
|
"rpc",
|
||||||
"rsa",
|
"rsa",
|
||||||
|
|
14
crates/project_panel/Cargo.toml
Normal file
14
crates/project_panel/Cargo.toml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
[package]
|
||||||
|
name = "project_panel"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
gpui = { path = "../gpui" }
|
||||||
|
project = { path = "../project" }
|
||||||
|
theme = { path = "../theme" }
|
||||||
|
workspace = { path = "../workspace" }
|
||||||
|
postage = { version = "0.4.1", features = ["futures-traits"] }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
serde_json = { version = "1.0.64", features = ["preserve_order"] }
|
|
@ -1,8 +1,3 @@
|
||||||
use crate::{
|
|
||||||
project::{self, Project, ProjectEntry, ProjectPath},
|
|
||||||
workspace::Workspace,
|
|
||||||
Settings,
|
|
||||||
};
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
action,
|
action,
|
||||||
elements::{
|
elements::{
|
||||||
|
@ -19,12 +14,13 @@ use gpui::{
|
||||||
ViewContext, ViewHandle, WeakViewHandle,
|
ViewContext, ViewHandle, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use postage::watch;
|
use postage::watch;
|
||||||
use project::Worktree;
|
use project::{Project, ProjectEntry, ProjectPath, Worktree};
|
||||||
use std::{
|
use std::{
|
||||||
collections::{hash_map, HashMap},
|
collections::{hash_map, HashMap},
|
||||||
ffi::OsStr,
|
ffi::OsStr,
|
||||||
ops::Range,
|
ops::Range,
|
||||||
};
|
};
|
||||||
|
use workspace::{Settings, Workspace};
|
||||||
|
|
||||||
pub struct ProjectPanel {
|
pub struct ProjectPanel {
|
||||||
project: ModelHandle<Project>,
|
project: ModelHandle<Project>,
|
||||||
|
@ -575,17 +571,16 @@ impl Entity for ProjectPanel {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::test::test_app_state;
|
|
||||||
use gpui::{TestAppContext, ViewHandle};
|
use gpui::{TestAppContext, ViewHandle};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use std::{collections::HashSet, path::Path};
|
use std::{collections::HashSet, path::Path};
|
||||||
|
use workspace::WorkspaceParams;
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
async fn test_visible_list(mut cx: gpui::TestAppContext) {
|
async fn test_visible_list(mut cx: gpui::TestAppContext) {
|
||||||
let app_state = cx.update(test_app_state);
|
let params = cx.update(WorkspaceParams::test);
|
||||||
let settings = app_state.settings.clone();
|
let settings = params.settings.clone();
|
||||||
let fs = app_state.fs.as_fake();
|
let fs = params.fs.as_fake();
|
||||||
|
|
||||||
fs.insert_tree(
|
fs.insert_tree(
|
||||||
"/root1",
|
"/root1",
|
||||||
json!({
|
json!({
|
||||||
|
@ -624,9 +619,9 @@ mod tests {
|
||||||
|
|
||||||
let project = cx.add_model(|_| {
|
let project = cx.add_model(|_| {
|
||||||
Project::new(
|
Project::new(
|
||||||
app_state.languages.clone(),
|
params.languages.clone(),
|
||||||
app_state.client.clone(),
|
params.client.clone(),
|
||||||
app_state.fs.clone(),
|
params.fs.clone(),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
let root1 = project
|
let root1 = project
|
||||||
|
@ -648,7 +643,7 @@ mod tests {
|
||||||
.read_with(&cx, |t, _| t.as_local().unwrap().scan_complete())
|
.read_with(&cx, |t, _| t.as_local().unwrap().scan_complete())
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let (_, workspace) = cx.add_window(|cx| Workspace::new(&app_state.as_ref().into(), cx));
|
let (_, workspace) = cx.add_window(|cx| Workspace::new(¶ms, cx));
|
||||||
let panel = workspace.update(&mut cx, |_, cx| ProjectPanel::new(project, settings, cx));
|
let panel = workspace.update(&mut cx, |_, cx| ProjectPanel::new(project, settings, cx));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
visible_entry_details(&panel, 0..50, &mut cx),
|
visible_entry_details(&panel, 0..50, &mut cx),
|
|
@ -32,6 +32,7 @@ fuzzy = { path = "../fuzzy" }
|
||||||
editor = { path = "../editor" }
|
editor = { path = "../editor" }
|
||||||
gpui = { path = "../gpui" }
|
gpui = { path = "../gpui" }
|
||||||
project = { path = "../project" }
|
project = { path = "../project" }
|
||||||
|
project_panel = { path = "../project_panel" }
|
||||||
rpc = { path = "../rpc" }
|
rpc = { path = "../rpc" }
|
||||||
sum_tree = { path = "../sum_tree" }
|
sum_tree = { path = "../sum_tree" }
|
||||||
theme = { path = "../theme" }
|
theme = { path = "../theme" }
|
||||||
|
|
|
@ -4,7 +4,6 @@ pub mod file_finder;
|
||||||
pub mod language;
|
pub mod language;
|
||||||
pub mod menus;
|
pub mod menus;
|
||||||
pub mod people_panel;
|
pub mod people_panel;
|
||||||
pub mod project_panel;
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
pub mod test;
|
pub mod test;
|
||||||
pub mod theme_selector;
|
pub mod theme_selector;
|
||||||
|
|
|
@ -16,7 +16,7 @@ use zed::{
|
||||||
client::{http, ChannelList, UserStore},
|
client::{http, ChannelList, UserStore},
|
||||||
editor, file_finder,
|
editor, file_finder,
|
||||||
fs::RealFs,
|
fs::RealFs,
|
||||||
language, menus, people_panel, project_panel, theme_selector, AppState, OpenParams, OpenPaths,
|
language, menus, people_panel, theme_selector, AppState, OpenParams, OpenPaths,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue