Honor cmd-w
to close active item
Co-Authored-By: Julia <julia@zed.dev>
This commit is contained in:
parent
b6914bf0fd
commit
d855e91e43
2 changed files with 25 additions and 16 deletions
|
@ -68,8 +68,12 @@ where
|
||||||
A: for<'a> Deserialize<'a> + PartialEq + Clone + Default + std::fmt::Debug + 'static,
|
A: for<'a> Deserialize<'a> + PartialEq + Clone + Default + std::fmt::Debug + 'static,
|
||||||
{
|
{
|
||||||
fn qualified_name() -> SharedString {
|
fn qualified_name() -> SharedString {
|
||||||
|
let name = type_name::<A>();
|
||||||
|
let mut separator_matches = name.rmatch_indices("::");
|
||||||
|
separator_matches.next().unwrap();
|
||||||
|
let name_start_ix = separator_matches.next().map_or(0, |(ix, _)| ix + 2);
|
||||||
// todo!() remove the 2 replacement when migration is done
|
// todo!() remove the 2 replacement when migration is done
|
||||||
type_name::<A>().replace("2::", "::").into()
|
name[name_start_ix..].replace("2::", "::").into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build(params: Option<serde_json::Value>) -> Result<Box<dyn Action>>
|
fn build(params: Option<serde_json::Value>) -> Result<Box<dyn Action>>
|
||||||
|
|
|
@ -733,21 +733,21 @@ impl Pane {
|
||||||
// self.activate_item(index, activate_pane, activate_pane, cx);
|
// self.activate_item(index, activate_pane, activate_pane, cx);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// pub fn close_active_item(
|
pub fn close_active_item(
|
||||||
// &mut self,
|
&mut self,
|
||||||
// action: &CloseActiveItem,
|
action: &CloseActiveItem,
|
||||||
// cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
// ) -> Option<Task<Result<()>>> {
|
) -> Option<Task<Result<()>>> {
|
||||||
// if self.items.is_empty() {
|
if self.items.is_empty() {
|
||||||
// return None;
|
return None;
|
||||||
// }
|
}
|
||||||
// let active_item_id = self.items[self.active_item_index].id();
|
let active_item_id = self.items[self.active_item_index].id();
|
||||||
// Some(self.close_item_by_id(
|
Some(self.close_item_by_id(
|
||||||
// active_item_id,
|
active_item_id,
|
||||||
// action.save_intent.unwrap_or(SaveIntent::Close),
|
action.save_intent.unwrap_or(SaveIntent::Close),
|
||||||
// cx,
|
cx,
|
||||||
// ))
|
))
|
||||||
// }
|
}
|
||||||
|
|
||||||
pub fn close_item_by_id(
|
pub fn close_item_by_id(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
@ -1919,7 +1919,12 @@ impl Render for Pane {
|
||||||
|
|
||||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||||
v_stack()
|
v_stack()
|
||||||
|
.context("Pane")
|
||||||
.size_full()
|
.size_full()
|
||||||
|
.on_action(|pane: &mut Self, action, cx| {
|
||||||
|
pane.close_active_item(action, cx)
|
||||||
|
.map(|task| task.detach_and_log_err(cx));
|
||||||
|
})
|
||||||
.child(self.render_tab_bar(cx))
|
.child(self.render_tab_bar(cx))
|
||||||
.child(div() /* todo!(toolbar) */)
|
.child(div() /* todo!(toolbar) */)
|
||||||
.child(if let Some(item) = self.active_item() {
|
.child(if let Some(item) = self.active_item() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue