Re-enable opening excerpts in Editor
This commit is contained in:
parent
0b7e324d86
commit
a8a5785ec5
2 changed files with 46 additions and 52 deletions
|
@ -8798,62 +8798,56 @@ impl Editor {
|
||||||
// self.searchable
|
// self.searchable
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// fn open_excerpts(workspace: &mut Workspace, _: &OpenExcerpts, cx: &mut ViewContext<Workspace>) {
|
fn open_excerpts(&mut self, _: &OpenExcerpts, cx: &mut ViewContext<Self>) {
|
||||||
// let active_item = workspace.active_item(cx);
|
let buffer = self.buffer.read(cx);
|
||||||
// let editor_handle = if let Some(editor) = active_item
|
if buffer.is_singleton() {
|
||||||
// .as_ref()
|
cx.propagate();
|
||||||
// .and_then(|item| item.act_as::<Self>(cx))
|
return;
|
||||||
// {
|
}
|
||||||
// editor
|
|
||||||
// } else {
|
|
||||||
// cx.propagate();
|
|
||||||
// return;
|
|
||||||
// };
|
|
||||||
|
|
||||||
// let editor = editor_handle.read(cx);
|
let Some(workspace) = self.workspace() else {
|
||||||
// let buffer = editor.buffer.read(cx);
|
cx.propagate();
|
||||||
// if buffer.is_singleton() {
|
return;
|
||||||
// cx.propagate();
|
};
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// let mut new_selections_by_buffer = HashMap::default();
|
let mut new_selections_by_buffer = HashMap::default();
|
||||||
// for selection in editor.selections.all::<usize>(cx) {
|
for selection in self.selections.all::<usize>(cx) {
|
||||||
// for (buffer, mut range, _) in
|
for (buffer, mut range, _) in
|
||||||
// buffer.range_to_buffer_ranges(selection.start..selection.end, cx)
|
buffer.range_to_buffer_ranges(selection.start..selection.end, cx)
|
||||||
// {
|
{
|
||||||
// if selection.reversed {
|
if selection.reversed {
|
||||||
// mem::swap(&mut range.start, &mut range.end);
|
mem::swap(&mut range.start, &mut range.end);
|
||||||
// }
|
}
|
||||||
// new_selections_by_buffer
|
new_selections_by_buffer
|
||||||
// .entry(buffer)
|
.entry(buffer)
|
||||||
// .or_insert(Vec::new())
|
.or_insert(Vec::new())
|
||||||
// .push(range)
|
.push(range)
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
// editor_handle.update(cx, |editor, cx| {
|
self.push_to_nav_history(self.selections.newest_anchor().head(), None, cx);
|
||||||
// editor.push_to_nav_history(editor.selections.newest_anchor().head(), None, cx);
|
|
||||||
// });
|
|
||||||
// let pane = workspace.active_pane().clone();
|
|
||||||
// pane.update(cx, |pane, _| pane.disable_history());
|
|
||||||
|
|
||||||
// // We defer the pane interaction because we ourselves are a workspace item
|
// We defer the pane interaction because we ourselves are a workspace item
|
||||||
// // and activating a new item causes the pane to call a method on us reentrantly,
|
// and activating a new item causes the pane to call a method on us reentrantly,
|
||||||
// // which panics if we're on the stack.
|
// which panics if we're on the stack.
|
||||||
// cx.defer(move |workspace, cx| {
|
cx.window_context().defer(move |cx| {
|
||||||
// for (buffer, ranges) in new_selections_by_buffer.into_iter() {
|
workspace.update(cx, |workspace, cx| {
|
||||||
// let editor = workspace.open_project_item::<Self>(buffer, cx);
|
let pane = workspace.active_pane().clone();
|
||||||
// editor.update(cx, |editor, cx| {
|
pane.update(cx, |pane, _| pane.disable_history());
|
||||||
// editor.change_selections(Some(Autoscroll::newest()), cx, |s| {
|
|
||||||
// s.select_ranges(ranges);
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// pane.update(cx, |pane, _| pane.enable_history());
|
for (buffer, ranges) in new_selections_by_buffer.into_iter() {
|
||||||
// });
|
let editor = workspace.open_project_item::<Self>(buffer, cx);
|
||||||
// }
|
editor.update(cx, |editor, cx| {
|
||||||
|
editor.change_selections(Some(Autoscroll::newest()), cx, |s| {
|
||||||
|
s.select_ranges(ranges);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pane.update(cx, |pane, _| pane.enable_history());
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
fn jump(
|
fn jump(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
|
@ -263,7 +263,7 @@ impl EditorElement {
|
||||||
register_action(view, cx, Editor::fold_selected_ranges);
|
register_action(view, cx, Editor::fold_selected_ranges);
|
||||||
register_action(view, cx, Editor::show_completions);
|
register_action(view, cx, Editor::show_completions);
|
||||||
register_action(view, cx, Editor::toggle_code_actions);
|
register_action(view, cx, Editor::toggle_code_actions);
|
||||||
// on_action(cx, Editor::open_excerpts); todo!()
|
register_action(view, cx, Editor::open_excerpts);
|
||||||
register_action(view, cx, Editor::toggle_soft_wrap);
|
register_action(view, cx, Editor::toggle_soft_wrap);
|
||||||
register_action(view, cx, Editor::toggle_inlay_hints);
|
register_action(view, cx, Editor::toggle_inlay_hints);
|
||||||
register_action(view, cx, hover_popover::hover);
|
register_action(view, cx, hover_popover::hover);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue