Move journal2 to workspace2
This commit is contained in:
parent
eb8a0e7148
commit
f1fc07de94
5 changed files with 82 additions and 81 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -4232,7 +4232,7 @@ dependencies = [
|
||||||
"settings2",
|
"settings2",
|
||||||
"shellexpand",
|
"shellexpand",
|
||||||
"util",
|
"util",
|
||||||
"workspace",
|
"workspace2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -12,7 +12,7 @@ doctest = false
|
||||||
editor = { path = "../editor" }
|
editor = { path = "../editor" }
|
||||||
gpui = { package = "gpui2", path = "../gpui2" }
|
gpui = { package = "gpui2", path = "../gpui2" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
workspace = { path = "../workspace" }
|
workspace2 = { path = "../workspace2" }
|
||||||
settings2 = { path = "../settings2" }
|
settings2 = { path = "../settings2" }
|
||||||
|
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
|
|
|
@ -9,7 +9,7 @@ use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use workspace::AppState;
|
use workspace2::AppState;
|
||||||
// use zed::AppState;
|
// use zed::AppState;
|
||||||
|
|
||||||
// todo!();
|
// todo!();
|
||||||
|
@ -59,7 +59,7 @@ pub fn init(_: Arc<AppState>, cx: &mut AppContext) {
|
||||||
// cx.add_global_action(move |_: &NewJournalEntry, cx| new_journal_entry(app_state.clone(), cx));
|
// cx.add_global_action(move |_: &NewJournalEntry, cx| new_journal_entry(app_state.clone(), cx));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_journal_entry(_: Arc<AppState>, cx: &mut AppContext) {
|
pub fn new_journal_entry(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||||
let settings = JournalSettings::get_global(cx);
|
let settings = JournalSettings::get_global(cx);
|
||||||
let journal_dir = match journal_dir(settings.path.as_ref().unwrap()) {
|
let journal_dir = match journal_dir(settings.path.as_ref().unwrap()) {
|
||||||
Some(journal_dir) => journal_dir,
|
Some(journal_dir) => journal_dir,
|
||||||
|
@ -77,7 +77,7 @@ pub fn new_journal_entry(_: Arc<AppState>, cx: &mut AppContext) {
|
||||||
let now = now.time();
|
let now = now.time();
|
||||||
let _entry_heading = heading_entry(now, &settings.hour_format);
|
let _entry_heading = heading_entry(now, &settings.hour_format);
|
||||||
|
|
||||||
let _create_entry = cx.background_executor().spawn(async move {
|
let create_entry = cx.background_executor().spawn(async move {
|
||||||
std::fs::create_dir_all(month_dir)?;
|
std::fs::create_dir_all(month_dir)?;
|
||||||
OpenOptions::new()
|
OpenOptions::new()
|
||||||
.create(true)
|
.create(true)
|
||||||
|
@ -86,37 +86,38 @@ pub fn new_journal_entry(_: Arc<AppState>, cx: &mut AppContext) {
|
||||||
Ok::<_, std::io::Error>((journal_dir, entry_path))
|
Ok::<_, std::io::Error>((journal_dir, entry_path))
|
||||||
});
|
});
|
||||||
|
|
||||||
// todo!("workspace")
|
cx.spawn(|mut cx| async move {
|
||||||
// cx.spawn(|cx| async move {
|
let (journal_dir, entry_path) = create_entry.await?;
|
||||||
// let (journal_dir, entry_path) = create_entry.await?;
|
let (workspace, _) = cx
|
||||||
// let (workspace, _) =
|
.update(|cx| workspace2::open_paths(&[journal_dir], &app_state, None, cx))?
|
||||||
// cx.update(|cx| workspace::open_paths(&[journal_dir], &app_state, None, cx))?;
|
.await?;
|
||||||
|
|
||||||
// let opened = workspace
|
let _opened = workspace
|
||||||
// .update(&mut cx, |workspace, cx| {
|
.update(&mut cx, |workspace, cx| {
|
||||||
// workspace.open_paths(vec![entry_path], true, cx)
|
workspace.open_paths(vec![entry_path], true, cx)
|
||||||
// })?
|
})?
|
||||||
// .await;
|
.await;
|
||||||
|
|
||||||
// if let Some(Some(Ok(item))) = opened.first() {
|
// todo!("editor")
|
||||||
// if let Some(editor) = item.downcast::<Editor>().map(|editor| editor.downgrade()) {
|
// if let Some(Some(Ok(item))) = opened.first() {
|
||||||
// editor.update(&mut cx, |editor, cx| {
|
// if let Some(editor) = item.downcast::<Editor>().map(|editor| editor.downgrade()) {
|
||||||
// let len = editor.buffer().read(cx).len(cx);
|
// editor.update(&mut cx, |editor, cx| {
|
||||||
// editor.change_selections(Some(Autoscroll::center()), cx, |s| {
|
// let len = editor.buffer().read(cx).len(cx);
|
||||||
// s.select_ranges([len..len])
|
// editor.change_selections(Some(Autoscroll::center()), cx, |s| {
|
||||||
// });
|
// s.select_ranges([len..len])
|
||||||
// if len > 0 {
|
// });
|
||||||
// editor.insert("\n\n", cx);
|
// if len > 0 {
|
||||||
// }
|
// editor.insert("\n\n", cx);
|
||||||
// editor.insert(&entry_heading, cx);
|
// }
|
||||||
// editor.insert("\n\n", cx);
|
// editor.insert(&entry_heading, cx);
|
||||||
// })?;
|
// editor.insert("\n\n", cx);
|
||||||
// }
|
// })?;
|
||||||
// }
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
// anyhow::Ok(())
|
anyhow::Ok(())
|
||||||
// })
|
})
|
||||||
// .detach_and_log_err(cx);
|
.detach_and_log_err(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn journal_dir(path: &str) -> Option<PathBuf> {
|
fn journal_dir(path: &str) -> Option<PathBuf> {
|
||||||
|
|
|
@ -12,6 +12,7 @@ use cli::{
|
||||||
CliRequest, CliResponse, IpcHandshake, FORCE_CLI_MODE_ENV_VAR_NAME,
|
CliRequest, CliResponse, IpcHandshake, FORCE_CLI_MODE_ENV_VAR_NAME,
|
||||||
};
|
};
|
||||||
use client::UserStore;
|
use client::UserStore;
|
||||||
|
use collections::HashMap;
|
||||||
use db::kvp::KEY_VALUE_STORE;
|
use db::kvp::KEY_VALUE_STORE;
|
||||||
use fs::RealFs;
|
use fs::RealFs;
|
||||||
use futures::{channel::mpsc, SinkExt, StreamExt};
|
use futures::{channel::mpsc, SinkExt, StreamExt};
|
||||||
|
@ -42,11 +43,13 @@ use std::{
|
||||||
thread,
|
thread,
|
||||||
time::{SystemTime, UNIX_EPOCH},
|
time::{SystemTime, UNIX_EPOCH},
|
||||||
};
|
};
|
||||||
|
use text::Point;
|
||||||
use util::{
|
use util::{
|
||||||
async_maybe,
|
async_maybe,
|
||||||
channel::{parse_zed_link, ReleaseChannel, RELEASE_CHANNEL},
|
channel::{parse_zed_link, ReleaseChannel, RELEASE_CHANNEL},
|
||||||
http::{self, HttpClient},
|
http::{self, HttpClient},
|
||||||
paths, ResultExt,
|
paths::{self, PathLikeWithPosition},
|
||||||
|
ResultExt,
|
||||||
};
|
};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use workspace2::{AppState, WorkspaceStore};
|
use workspace2::{AppState, WorkspaceStore};
|
||||||
|
@ -228,10 +231,8 @@ fn main() {
|
||||||
let mut _triggered_authentication = false;
|
let mut _triggered_authentication = false;
|
||||||
|
|
||||||
match open_rx.try_next() {
|
match open_rx.try_next() {
|
||||||
Ok(Some(OpenRequest::Paths { paths: _ })) => {
|
Ok(Some(OpenRequest::Paths { paths })) => {
|
||||||
// todo!("workspace")
|
workspace2::open_paths(&paths, &app_state, None, cx).detach();
|
||||||
// cx.update(|cx| workspace::open_paths(&paths, &app_state, None, cx))
|
|
||||||
// .detach();
|
|
||||||
}
|
}
|
||||||
Ok(Some(OpenRequest::CliConnection { connection })) => {
|
Ok(Some(OpenRequest::CliConnection { connection })) => {
|
||||||
let app_state = app_state.clone();
|
let app_state = app_state.clone();
|
||||||
|
@ -263,10 +264,10 @@ fn main() {
|
||||||
async move {
|
async move {
|
||||||
while let Some(request) = open_rx.next().await {
|
while let Some(request) = open_rx.next().await {
|
||||||
match request {
|
match request {
|
||||||
OpenRequest::Paths { paths: _ } => {
|
OpenRequest::Paths { paths } => {
|
||||||
// todo!("workspace")
|
cx.update(|cx| workspace2::open_paths(&paths, &app_state, None, cx))
|
||||||
// cx.update(|cx| workspace::open_paths(&paths, &app_state, None, cx))
|
.ok()
|
||||||
// .detach();
|
.map(|t| t.detach());
|
||||||
}
|
}
|
||||||
OpenRequest::CliConnection { connection } => {
|
OpenRequest::CliConnection { connection } => {
|
||||||
let app_state = app_state.clone();
|
let app_state = app_state.clone();
|
||||||
|
@ -781,45 +782,45 @@ async fn handle_cli_connection(
|
||||||
) {
|
) {
|
||||||
if let Some(request) = requests.next().await {
|
if let Some(request) = requests.next().await {
|
||||||
match request {
|
match request {
|
||||||
CliRequest::Open { paths: _, wait: _ } => {
|
CliRequest::Open { paths, wait } => {
|
||||||
// let mut caret_positions = HashMap::new();
|
let mut caret_positions = HashMap::default();
|
||||||
|
|
||||||
// todo!("workspace")
|
let paths = if paths.is_empty() {
|
||||||
// let paths = if paths.is_empty() {
|
workspace2::last_opened_workspace_paths()
|
||||||
// workspace::last_opened_workspace_paths()
|
.await
|
||||||
// .await
|
.map(|location| location.paths().to_vec())
|
||||||
// .map(|location| location.paths().to_vec())
|
.unwrap_or_default()
|
||||||
// .unwrap_or_default()
|
} else {
|
||||||
// } else {
|
paths
|
||||||
// paths
|
.into_iter()
|
||||||
// .into_iter()
|
.filter_map(|path_with_position_string| {
|
||||||
// .filter_map(|path_with_position_string| {
|
let path_with_position = PathLikeWithPosition::parse_str(
|
||||||
// let path_with_position = PathLikeWithPosition::parse_str(
|
&path_with_position_string,
|
||||||
// &path_with_position_string,
|
|path_str| {
|
||||||
// |path_str| {
|
Ok::<_, std::convert::Infallible>(
|
||||||
// Ok::<_, std::convert::Infallible>(
|
Path::new(path_str).to_path_buf(),
|
||||||
// Path::new(path_str).to_path_buf(),
|
)
|
||||||
// )
|
},
|
||||||
// },
|
)
|
||||||
// )
|
.expect("Infallible");
|
||||||
// .expect("Infallible");
|
let path = path_with_position.path_like;
|
||||||
// let path = path_with_position.path_like;
|
if let Some(row) = path_with_position.row {
|
||||||
// if let Some(row) = path_with_position.row {
|
if path.is_file() {
|
||||||
// if path.is_file() {
|
let row = row.saturating_sub(1);
|
||||||
// let row = row.saturating_sub(1);
|
let col =
|
||||||
// let col =
|
path_with_position.column.unwrap_or(0).saturating_sub(1);
|
||||||
// path_with_position.column.unwrap_or(0).saturating_sub(1);
|
caret_positions.insert(path.clone(), Point::new(row, col));
|
||||||
// caret_positions.insert(path.clone(), Point::new(row, col));
|
}
|
||||||
// }
|
}
|
||||||
// }
|
Some(path)
|
||||||
// Some(path)
|
})
|
||||||
// })
|
.collect()
|
||||||
// .collect()
|
};
|
||||||
// };
|
|
||||||
|
|
||||||
|
// todo!("editor")
|
||||||
// let mut errored = false;
|
// let mut errored = false;
|
||||||
// match cx
|
// match cx
|
||||||
// .update(|cx| workspace::open_paths(&paths, &app_state, None, cx))
|
// .update(|cx| workspace2::open_paths(&paths, &app_state, None, cx))
|
||||||
// .await
|
// .await
|
||||||
// {
|
// {
|
||||||
// Ok((workspace, items)) => {
|
// Ok((workspace, items)) => {
|
||||||
|
|
|
@ -37,10 +37,9 @@ pub enum IsOnlyInstance {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ensure_only_instance() -> IsOnlyInstance {
|
pub fn ensure_only_instance() -> IsOnlyInstance {
|
||||||
// todo!("zed_stateless")
|
if *db::ZED_STATELESS {
|
||||||
// if *db::ZED_STATELESS {
|
return IsOnlyInstance::Yes;
|
||||||
// return IsOnlyInstance::Yes;
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
if check_got_handshake() {
|
if check_got_handshake() {
|
||||||
return IsOnlyInstance::No;
|
return IsOnlyInstance::No;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue