Finish implementing ProjectDiagnostics::open_excerpts

* Build workspace item views with a reference to the workspace
* Add randomized test for MultiBuffer::excerpted_buffers and fix a small bug

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Max Brunsfeld
2022-01-07 09:59:27 -08:00
co-authored by Nathan Sobo
parent e5c520a265
commit ea263822fa
5 changed files with 107 additions and 45 deletions
+7 -2
View File
@@ -13,6 +13,7 @@ use std::path::Path;
use text::{Point, Selection};
use workspace::{
ItemHandle, ItemView, ItemViewHandle, PathOpener, Settings, StatusItemView, WeakItemHandle,
Workspace,
};
pub struct BufferOpener;
@@ -43,13 +44,17 @@ impl ItemHandle for BufferItemHandle {
fn add_view(
&self,
window_id: usize,
settings: watch::Receiver<Settings>,
workspace: &Workspace,
cx: &mut MutableAppContext,
) -> Box<dyn ItemViewHandle> {
let buffer = cx.add_model(|cx| MultiBuffer::singleton(self.0.clone(), cx));
let weak_buffer = buffer.downgrade();
Box::new(cx.add_view(window_id, |cx| {
Editor::for_buffer(buffer, crate::settings_builder(weak_buffer, settings), cx)
Editor::for_buffer(
buffer,
crate::settings_builder(weak_buffer, workspace.settings()),
cx,
)
}))
}