Add excerpts into outline panel (#13034)

Follow-up of https://github.com/zed-industries/zed/pull/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
This commit is contained in:
Kirill Bulatov 2024-06-14 12:03:16 +03:00 committed by GitHub
parent 1248788780
commit eb7a09b459
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 1106 additions and 894 deletions

3
Cargo.lock generated
View File

@ -7160,8 +7160,9 @@ dependencies = [
"db",
"editor",
"file_icons",
"git",
"futures 0.3.28",
"gpui",
"itertools 0.11.0",
"language",
"log",
"menu",

View File

@ -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();
}

View File

@ -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),
@ -11818,7 +11818,7 @@ pub enum EditorEvent {
Edited {
transaction_id: clock::Lamport,
},
Reparsed,
Reparsed(BufferId),
Focused,
Blurred,
DirtyChanged,

View File

@ -903,7 +903,7 @@ impl Item for Editor {
f(ItemEvent::UpdateBreadcrumbs);
}
EditorEvent::Reparsed => {
EditorEvent::Reparsed(_) => {
f(ItemEvent::UpdateBreadcrumbs);
}

View File

@ -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,
};

View File

@ -94,9 +94,9 @@ pub enum Event {
DiffUpdated {
buffer: Model<Buffer>,
},
LanguageChanged,
LanguageChanged(BufferId),
CapabilityChanged,
Reparsed,
Reparsed(BufferId),
Saved,
FileHandleChanged,
Closed,
@ -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 {
@ -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 => {

View File

@ -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

File diff suppressed because it is too large Load Diff