Merge branch 'master' into copy-paste

This commit is contained in:
Antonio Scandurra
2021-04-14 12:05:52 +02:00
10 changed files with 102 additions and 84 deletions
+2 -2
View File
@@ -51,8 +51,8 @@ fn open_paths(params: &OpenParams, app: &mut MutableAppContext) {
for window_id in app.window_ids().collect::<Vec<_>>() {
if let Some(handle) = app.root_view::<WorkspaceView>(window_id) {
if handle.update(app, |view, ctx| {
if view.contains_paths(&params.paths, ctx.app()) {
view.open_paths(&params.paths, ctx.app_mut());
if view.contains_paths(&params.paths, ctx.as_ref()) {
view.open_paths(&params.paths, ctx.as_mut());
log::info!("open paths on existing workspace");
true
} else {
+4 -5
View File
@@ -110,11 +110,10 @@ impl Pane {
entry_id: (usize, usize),
ctx: &mut ViewContext<Self>,
) -> bool {
if let Some(index) = self
.items
.iter()
.position(|item| item.entry_id(ctx.app()).map_or(false, |id| id == entry_id))
{
if let Some(index) = self.items.iter().position(|item| {
item.entry_id(ctx.as_ref())
.map_or(false, |id| id == entry_id)
}) {
self.activate_item(index, ctx);
true
} else {
+2 -2
View File
@@ -153,8 +153,8 @@ impl Workspace {
.ok_or(anyhow!("worktree {} does not exist", entry.0,))?;
let replica_id = self.replica_id;
let file = worktree.file(entry.1, ctx.app())?;
let history = file.load_history(ctx.app());
let file = worktree.file(entry.1, ctx.as_ref())?;
let history = file.load_history(ctx.as_ref());
let buffer = async move { Ok(Buffer::from_history(replica_id, file, history.await?)) };
let (mut tx, rx) = watch::channel(None);
+5 -5
View File
@@ -214,7 +214,7 @@ impl WorkspaceView {
me.loading_entries.remove(&entry);
match item {
Ok(item) => {
let item_view = item.add_view(ctx.window_id(), settings, ctx.app_mut());
let item_view = item.add_view(ctx.window_id(), settings, ctx.as_mut());
me.add_item(item_view, ctx);
}
Err(error) => {
@@ -243,7 +243,7 @@ impl WorkspaceView {
pub fn save_active_item(&mut self, _: &(), ctx: &mut ViewContext<Self>) {
self.active_pane.update(ctx, |pane, ctx| {
if let Some(item) = pane.active_item() {
let task = item.save(ctx.app_mut());
let task = item.save(ctx.as_mut());
ctx.spawn(task, |_, result, _| {
if let Err(e) = result {
// TODO - present this error to the user
@@ -259,7 +259,7 @@ impl WorkspaceView {
match to_string_pretty(&ctx.debug_elements()) {
Ok(json) => {
let kib = json.len() as f32 / 1024.;
ctx.app_mut().write_to_clipboard(ClipboardItem::new(json));
ctx.as_mut().write_to_clipboard(ClipboardItem::new(json));
log::info!(
"copied {:.1} KiB of element debug JSON to the clipboard",
kib
@@ -324,7 +324,7 @@ impl WorkspaceView {
let new_pane = self.add_pane(ctx);
self.activate_pane(new_pane.clone(), ctx);
if let Some(item) = pane.read(ctx).active_item() {
if let Some(clone) = item.clone_on_split(ctx.app_mut()) {
if let Some(clone) = item.clone_on_split(ctx.as_mut()) {
self.add_item(clone, ctx);
}
}
@@ -352,7 +352,7 @@ impl WorkspaceView {
fn add_item(&self, item: Box<dyn ItemViewHandle>, ctx: &mut ViewContext<Self>) {
let active_pane = self.active_pane();
item.set_parent_pane(&active_pane, ctx.app_mut());
item.set_parent_pane(&active_pane, ctx.as_mut());
active_pane.update(ctx, |pane, ctx| {
let item_idx = pane.add_item(item, ctx);
pane.activate_item(item_idx, ctx);