Skip to content

Commit

Permalink
Add excerpts into outline panel (#13034)
Browse files Browse the repository at this point in the history
Follow-up of #12637

Adds excerpt items into the outline panel: now all outline items are
initially hidden under excerpt items that could be toggled open/closed
similar to directories.


![Screenshot 2024-06-14 at 10 45
04](https://github.com/zed-industries/zed/assets/2690773/9c9ef91b-1666-43c3-acc4-96f850098a28)

On active editor's selection change, a corresponding outline will be
revealed still, expanding the corresponding excerpt

![Screenshot 2024-06-14 at 10 45
13](https://github.com/zed-industries/zed/assets/2690773/7dfd14f7-4aca-48f2-8760-8e1362b9a043)

Release Notes:

- N/A
  • Loading branch information
SomeoneToIgnore authored Jun 14, 2024
1 parent 1248788 commit eb7a09b
Show file tree
Hide file tree
Showing 8 changed files with 1,107 additions and 895 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/collab_ui/src/channel_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl ChannelView {
&self.editor,
move |this, _, e: &EditorEvent, cx| {
match e {
EditorEvent::Reparsed => {
EditorEvent::Reparsed(_) => {
this.focus_position_from_link(position.clone(), false, cx);
this._reparse_subscription.take();
}
Expand Down
10 changes: 5 additions & 5 deletions crates/editor/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10888,14 +10888,14 @@ impl Editor {
multi_buffer::Event::ExcerptsExpanded { ids } => {
cx.emit(EditorEvent::ExcerptsExpanded { ids: ids.clone() })
}
multi_buffer::Event::Reparsed => {
multi_buffer::Event::Reparsed(buffer_id) => {
self.tasks_update_task = Some(self.refresh_runnables(cx));

cx.emit(EditorEvent::Reparsed);
cx.emit(EditorEvent::Reparsed(*buffer_id));
}
multi_buffer::Event::LanguageChanged => {
multi_buffer::Event::LanguageChanged(buffer_id) => {
linked_editing_ranges::refresh_linked_ranges(self, cx);
cx.emit(EditorEvent::Reparsed);
cx.emit(EditorEvent::Reparsed(*buffer_id));
cx.notify();
}
multi_buffer::Event::DirtyChanged => cx.emit(EditorEvent::DirtyChanged),
Expand Down Expand Up @@ -11818,7 +11818,7 @@ pub enum EditorEvent {
Edited {
transaction_id: clock::Lamport,
},
Reparsed,
Reparsed(BufferId),
Focused,
Blurred,
DirtyChanged,
Expand Down
2 changes: 1 addition & 1 deletion crates/editor/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ impl Item for Editor {
f(ItemEvent::UpdateBreadcrumbs);
}

EditorEvent::Reparsed => {
EditorEvent::Reparsed(_) => {
f(ItemEvent::UpdateBreadcrumbs);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/language_tools/src/syntax_tree_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl SyntaxTreeView {

let subscription = cx.subscribe(&editor, |this, _, event, cx| {
let did_reparse = match event {
editor::EditorEvent::Reparsed => true,
editor::EditorEvent::Reparsed(_) => true,
editor::EditorEvent::SelectionsChanged { .. } => false,
_ => return,
};
Expand Down
14 changes: 9 additions & 5 deletions crates/multi_buffer/src/multi_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ pub enum Event {
DiffUpdated {
buffer: Model<Buffer>,
},
LanguageChanged,
LanguageChanged(BufferId),
CapabilityChanged,
Reparsed,
Reparsed(BufferId),
Saved,
FileHandleChanged,
Closed,
Expand Down Expand Up @@ -538,9 +538,13 @@ impl MultiBuffer {
});

if let Some(buffer) = self.as_singleton() {
return buffer.update(cx, |buffer, cx| {
buffer.update(cx, |buffer, cx| {
buffer.edit(edits, autoindent_mode, cx);
});
cx.emit(Event::ExcerptsEdited {
ids: self.excerpt_ids(),
});
return;
}

let original_indent_columns = match &mut autoindent_mode {
Expand Down Expand Up @@ -1639,8 +1643,8 @@ impl MultiBuffer {
language::Event::Reloaded => Event::Reloaded,
language::Event::DiffBaseChanged => Event::DiffBaseChanged,
language::Event::DiffUpdated => Event::DiffUpdated { buffer },
language::Event::LanguageChanged => Event::LanguageChanged,
language::Event::Reparsed => Event::Reparsed,
language::Event::LanguageChanged => Event::LanguageChanged(buffer.read(cx).remote_id()),
language::Event::Reparsed => Event::Reparsed(buffer.read(cx).remote_id()),
language::Event::DiagnosticsUpdated => Event::DiagnosticsUpdated,
language::Event::Closed => Event::Closed,
language::Event::CapabilityChanged => {
Expand Down
3 changes: 2 additions & 1 deletion crates/outline_panel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ collections.workspace = true
db.workspace = true
editor.workspace = true
file_icons.workspace = true
git.workspace = true
futures.workspace = true
itertools.workspace = true
gpui.workspace = true
language.workspace = true
log.workspace = true
Expand Down
Loading

0 comments on commit eb7a09b

Please sign in to comment.