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