Merge pull request #1084 from zed-industries/private-projects

Offline projects
This commit is contained in:
Max Brunsfeld 2022-06-03 17:14:46 -07:00 committed by GitHub
commit ff3e3d0799
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 2301 additions and 1234 deletions

View file

@ -59,7 +59,7 @@ chrono = "0.4"
ctor = "0.1.20"
dirs = "3.0"
easy-parallel = "3.1.0"
env_logger = "0.8"
env_logger = "0.9"
futures = "0.3"
http-auth-basic = "0.1.3"
ignore = "0.4"
@ -108,7 +108,7 @@ client = { path = "../client", features = ["test-support"] }
settings = { path = "../settings", features = ["test-support"] }
util = { path = "../util", features = ["test-support"] }
workspace = { path = "../workspace", features = ["test-support"] }
env_logger = "0.8"
env_logger = "0.9"
serde_json = { version = "1.0", features = ["preserve_order"] }
unindent = "0.1.7"

View file

@ -23,7 +23,7 @@ use gpui::{executor::Background, App, AssetSource, AsyncAppContext, Task};
use isahc::{config::Configurable, AsyncBody, Request};
use log::LevelFilter;
use parking_lot::Mutex;
use project::Fs;
use project::{Fs, ProjectStore};
use serde_json::json;
use settings::{self, KeymapFileContent, Settings, SettingsFileContent};
use smol::process::Command;
@ -48,9 +48,10 @@ use zed::{
fn main() {
let http = http::client();
let logs_dir_path = dirs::home_dir()
.expect("could not find home dir")
.join("Library/Logs/Zed");
let home_dir = dirs::home_dir().expect("could not find home dir");
let db_dir_path = home_dir.join("Library/Application Support/Zed");
let logs_dir_path = home_dir.join("Library/Logs/Zed");
fs::create_dir_all(&db_dir_path).expect("could not create database path");
fs::create_dir_all(&logs_dir_path).expect("could not create logs path");
init_logger(&logs_dir_path);
@ -59,6 +60,11 @@ fn main() {
.or_else(|| app.platform().app_version().ok())
.map_or("dev".to_string(), |v| v.to_string());
init_panic_hook(logs_dir_path, app_version, http.clone(), app.background());
let db = app.background().spawn(async move {
project::Db::open(db_dir_path.join("zed.db"))
.log_err()
.unwrap_or(project::Db::null())
});
load_embedded_fonts(&app);
@ -169,6 +175,7 @@ fn main() {
search::init(cx);
vim::init(cx);
let db = cx.background().block(db);
let (settings_file, keymap_file) = cx.background().block(config_files).unwrap();
let mut settings_rx = settings_from_files(
default_settings,
@ -204,11 +211,13 @@ fn main() {
.detach();
cx.set_global(settings);
let project_store = cx.add_model(|_| ProjectStore::new(db));
let app_state = Arc::new(AppState {
languages,
themes,
client: client.clone(),
user_store,
project_store,
fs,
build_window_options,
initialize_workspace,

View file

@ -181,7 +181,12 @@ pub fn initialize_workspace(
let project_panel = ProjectPanel::new(workspace.project().clone(), cx);
let contact_panel = cx.add_view(|cx| {
ContactsPanel::new(app_state.user_store.clone(), workspace.weak_handle(), cx)
ContactsPanel::new(
app_state.user_store.clone(),
app_state.project_store.clone(),
workspace.weak_handle(),
cx,
)
});
workspace.left_sidebar().update(cx, |sidebar, cx| {
@ -295,8 +300,10 @@ fn open_config_file(
let (_, workspace) = cx.add_window((app_state.build_window_options)(), |cx| {
let mut workspace = Workspace::new(
Project::local(
false,
app_state.client.clone(),
app_state.user_store.clone(),
app_state.project_store.clone(),
app_state.languages.clone(),
app_state.fs.clone(),
cx,