mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-19 18:41:56 +03:00
wip serialize editor
This commit is contained in:
parent
d20d21c6a2
commit
75d3d46b1b
@ -373,6 +373,7 @@ pub fn init(cx: &mut MutableAppContext) {
|
||||
|
||||
workspace::register_project_item::<Editor>(cx);
|
||||
workspace::register_followable_item::<Editor>(cx);
|
||||
workspace::register_deserializable_item::<Editor>(cx);
|
||||
}
|
||||
|
||||
trait InvalidationRegion {
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::{
|
||||
display_map::ToDisplayPoint, link_go_to_definition::hide_link_definition,
|
||||
movement::surrounding_word, Anchor, Autoscroll, Editor, Event, ExcerptId, MultiBuffer,
|
||||
MultiBufferSnapshot, NavigationData, ToPoint as _, FORMAT_TIMEOUT,
|
||||
movement::surrounding_word, Anchor, Autoscroll, Editor, EditorMode, Event, ExcerptId,
|
||||
MultiBuffer, MultiBufferSnapshot, NavigationData, ToPoint as _, FORMAT_TIMEOUT,
|
||||
};
|
||||
use anyhow::{anyhow, Result};
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use futures::FutureExt;
|
||||
use gpui::{
|
||||
elements::*, geometry::vector::vec2f, AppContext, Entity, ModelHandle, MutableAppContext,
|
||||
@ -558,14 +558,36 @@ impl Item for Editor {
|
||||
}
|
||||
|
||||
fn deserialize(
|
||||
_project: ModelHandle<Project>,
|
||||
project: ModelHandle<Project>,
|
||||
_workspace: WeakViewHandle<Workspace>,
|
||||
_workspace_id: WorkspaceId,
|
||||
_item_id: ItemId,
|
||||
_cx: &mut ViewContext<Pane>,
|
||||
cx: &mut ViewContext<Pane>,
|
||||
) -> Task<Result<ViewHandle<Self>>> {
|
||||
// Look up the path with this key associated, create a self with that path
|
||||
unimplemented!()
|
||||
let path = Path::new(".");
|
||||
if let Some(project_item) = project.update(cx, |project, cx| {
|
||||
let (worktree, path) = project.find_local_worktree(path, cx)?;
|
||||
let project_path = ProjectPath {
|
||||
worktree_id: worktree.read(cx).id(),
|
||||
path: path.into(),
|
||||
};
|
||||
|
||||
Some(project.open_path(project_path, cx))
|
||||
}) {
|
||||
cx.spawn(|pane, mut cx| async move {
|
||||
let (_, project_item) = project_item.await?;
|
||||
let buffer = project_item
|
||||
.downcast::<Buffer>()
|
||||
.context("Project item at stored path was not a buffer")?;
|
||||
|
||||
Ok(cx.update(|cx| {
|
||||
cx.add_view(pane, |cx| Editor::for_buffer(buffer, Some(project), cx))
|
||||
}))
|
||||
})
|
||||
} else {
|
||||
Task::ready(Err(anyhow!("Could not load file from stored path")))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,8 +69,6 @@ use lazy_static::lazy_static;
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
terminal_view::init(cx);
|
||||
terminal_container_view::init(cx);
|
||||
|
||||
register_deserializable_item::<TerminalContainer>(cx);
|
||||
}
|
||||
|
||||
///Scrolling is unbearably sluggish by default. Alacritty supports a configurable
|
||||
|
Loading…
Reference in New Issue
Block a user