Remove Editor::find_or_create

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra
2022-03-17 15:13:47 +01:00
co-authored by Nathan Sobo
parent 6f9c37851c
commit bff414cfbc
6 changed files with 63 additions and 28 deletions
+14 -2
View File
@@ -4,13 +4,13 @@ use gpui::{
elements::*, AppContext, Entity, ModelHandle, RenderContext, Subscription, Task, View,
ViewContext, ViewHandle,
};
use language::{Bias, Diagnostic, File as _};
use language::{Bias, Buffer, Diagnostic, File as _};
use project::{File, Project, ProjectPath};
use std::fmt::Write;
use std::path::PathBuf;
use text::{Point, Selection};
use util::ResultExt;
use workspace::{Item, ItemHandle, ItemNavHistory, Settings, StatusItemView};
use workspace::{Item, ItemHandle, ItemNavHistory, ProjectItem, Settings, StatusItemView};
impl Item for Editor {
fn navigate(&mut self, data: Box<dyn std::any::Any>, cx: &mut ViewContext<Self>) {
@@ -132,6 +132,18 @@ impl Item for Editor {
}
}
impl ProjectItem for Editor {
type Item = Buffer;
fn for_project_item(
project: ModelHandle<Project>,
buffer: ModelHandle<Buffer>,
cx: &mut ViewContext<Self>,
) -> Self {
Self::for_buffer(buffer, Some(project), cx)
}
}
pub struct CursorPosition {
position: Option<Point>,
selected_count: usize,