Skip to content

Commit be57636

Browse files
Start removing callers of legacy excerpt APIs (zed-industries#50144)
Paving the way to remove `ExcerptId`. Done in this PR: - Unshipped the stack trace view - Get rid of `push_excerpts` - Get rid of some callers of `remove_excerpts` We still need to remove some calls to `remove_excerpts` and other APIs, especially in `randomly_edit_excerpts` and collaboration. Release Notes: - The stack trace multibuffer view has been removed. --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
1 parent 8b2829e commit be57636

23 files changed

Lines changed: 910 additions & 1429 deletions

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/agent_ui/src/inline_assistant.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use editor::RowExt;
2626
use editor::SelectionEffects;
2727
use editor::scroll::ScrollOffset;
2828
use editor::{
29-
Anchor, AnchorRangeExt, CodeActionProvider, Editor, EditorEvent, ExcerptId, ExcerptRange,
30-
HighlightKey, MultiBuffer, MultiBufferSnapshot, ToOffset as _, ToPoint,
29+
Anchor, AnchorRangeExt, CodeActionProvider, Editor, EditorEvent, ExcerptId, HighlightKey,
30+
MultiBuffer, MultiBufferSnapshot, ToOffset as _, ToPoint,
3131
actions::SelectAll,
3232
display_map::{
3333
BlockContext, BlockPlacement, BlockProperties, BlockStyle, CustomBlockId, EditorMargins,
@@ -1495,11 +1495,11 @@ impl InlineAssistant {
14951495

14961496
let mut new_blocks = Vec::new();
14971497
for (new_row, old_row_range) in deleted_row_ranges {
1498-
let (_, buffer_start) = old_snapshot
1499-
.point_to_buffer_offset(Point::new(*old_row_range.start(), 0))
1498+
let (_, start, _) = old_snapshot
1499+
.point_to_buffer_point(Point::new(*old_row_range.start(), 0))
15001500
.unwrap();
1501-
let (_, buffer_end) = old_snapshot
1502-
.point_to_buffer_offset(Point::new(
1501+
let (_, end, _) = old_snapshot
1502+
.point_to_buffer_point(Point::new(
15031503
*old_row_range.end(),
15041504
old_snapshot.line_len(MultiBufferRow(*old_row_range.end())),
15051505
))
@@ -1509,10 +1509,11 @@ impl InlineAssistant {
15091509
let multi_buffer =
15101510
cx.new(|_| MultiBuffer::without_headers(language::Capability::ReadOnly));
15111511
multi_buffer.update(cx, |multi_buffer, cx| {
1512-
multi_buffer.push_excerpts(
1512+
multi_buffer.set_excerpts_for_buffer(
15131513
old_buffer.clone(),
1514-
// todo(lw): buffer_start and buffer_end might come from different snapshots!
1515-
Some(ExcerptRange::new(buffer_start..buffer_end)),
1514+
// todo(lw): start and end might come from different snapshots!
1515+
[start..end],
1516+
0,
15161517
cx,
15171518
);
15181519
});

crates/copilot/src/copilot_edit_prediction_delegate.rs

Lines changed: 83 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,8 @@ mod tests {
233233
use super::*;
234234
use edit_prediction_types::EditPredictionGranularity;
235235
use editor::{
236-
Editor, ExcerptRange, MultiBuffer, MultiBufferOffset, SelectionEffects,
237-
test::editor_lsp_test_context::EditorLspTestContext,
236+
Editor, MultiBuffer, MultiBufferOffset, PathKey, SelectionEffects,
237+
test::{editor_content_with_blocks, editor_lsp_test_context::EditorLspTestContext},
238238
};
239239
use fs::FakeFs;
240240
use futures::StreamExt;
@@ -685,32 +685,32 @@ mod tests {
685685
let buffer_2 = cx.new(|cx| Buffer::local("c = 3\nd = 4\n", cx));
686686
let multibuffer = cx.new(|cx| {
687687
let mut multibuffer = MultiBuffer::new(language::Capability::ReadWrite);
688-
multibuffer.push_excerpts(
688+
multibuffer.set_excerpts_for_path(
689+
PathKey::sorted(0),
689690
buffer_1.clone(),
690-
[ExcerptRange::new(Point::new(0, 0)..Point::new(2, 0))],
691+
[Point::new(0, 0)..Point::new(1, 0)],
692+
0,
691693
cx,
692694
);
693-
multibuffer.push_excerpts(
695+
multibuffer.set_excerpts_for_path(
696+
PathKey::sorted(1),
694697
buffer_2.clone(),
695-
[ExcerptRange::new(Point::new(0, 0)..Point::new(2, 0))],
698+
[Point::new(0, 0)..Point::new(1, 0)],
699+
0,
696700
cx,
697701
);
698702
multibuffer
699703
});
700-
let editor =
701-
cx.add_window(|window, cx| Editor::for_multibuffer(multibuffer, None, window, cx));
702-
editor
703-
.update(cx, |editor, window, cx| {
704-
use gpui::Focusable;
705-
window.focus(&editor.focus_handle(cx), cx);
706-
})
707-
.unwrap();
704+
let (editor, cx) =
705+
cx.add_window_view(|window, cx| Editor::for_multibuffer(multibuffer, None, window, cx));
706+
editor.update_in(cx, |editor, window, cx| {
707+
use gpui::Focusable;
708+
window.focus(&editor.focus_handle(cx), cx);
709+
});
708710
let copilot_provider = cx.new(|_| CopilotEditPredictionDelegate::new(copilot));
709-
editor
710-
.update(cx, |editor, window, cx| {
711-
editor.set_edit_prediction_provider(Some(copilot_provider), window, cx)
712-
})
713-
.unwrap();
711+
editor.update_in(cx, |editor, window, cx| {
712+
editor.set_edit_prediction_provider(Some(copilot_provider), window, cx)
713+
});
714714

715715
handle_copilot_completion_request(
716716
&copilot_lsp,
@@ -724,22 +724,30 @@ mod tests {
724724
},
725725
}],
726726
);
727-
_ = editor.update(cx, |editor, window, cx| {
727+
_ = editor.update_in(cx, |editor, window, cx| {
728728
// Ensure copilot suggestions are shown for the first excerpt.
729729
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
730730
s.select_ranges([Point::new(1, 5)..Point::new(1, 5)])
731731
});
732732
editor.show_edit_prediction(&Default::default(), window, cx);
733733
});
734734
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
735-
_ = editor.update(cx, |editor, _, cx| {
735+
_ = editor.update_in(cx, |editor, _, _| {
736736
assert!(editor.has_active_edit_prediction());
737-
assert_eq!(
738-
editor.display_text(cx),
739-
"\n\na = 1\nb = 2 + a\n\n\n\nc = 3\nd = 4\n"
740-
);
741-
assert_eq!(editor.text(cx), "a = 1\nb = 2\n\nc = 3\nd = 4\n");
742737
});
738+
pretty_assertions::assert_eq!(
739+
editor_content_with_blocks(&editor, cx),
740+
indoc! { "
741+
§ <no file>
742+
§ -----
743+
a = 1
744+
b = 2 + a
745+
§ <no file>
746+
§ -----
747+
c = 3
748+
d = 4"
749+
}
750+
);
743751

744752
handle_copilot_completion_request(
745753
&copilot_lsp,
@@ -753,38 +761,61 @@ mod tests {
753761
},
754762
}],
755763
);
756-
_ = editor.update(cx, |editor, window, cx| {
764+
_ = editor.update_in(cx, |editor, window, cx| {
757765
// Move to another excerpt, ensuring the suggestion gets cleared.
758766
editor.change_selections(SelectionEffects::no_scroll(), window, cx, |s| {
759767
s.select_ranges([Point::new(4, 5)..Point::new(4, 5)])
760768
});
761769
assert!(!editor.has_active_edit_prediction());
762-
assert_eq!(
763-
editor.display_text(cx),
764-
"\n\na = 1\nb = 2\n\n\n\nc = 3\nd = 4\n"
765-
);
766-
assert_eq!(editor.text(cx), "a = 1\nb = 2\n\nc = 3\nd = 4\n");
767-
770+
});
771+
pretty_assertions::assert_eq!(
772+
editor_content_with_blocks(&editor, cx),
773+
indoc! { "
774+
§ <no file>
775+
§ -----
776+
a = 1
777+
b = 2
778+
§ <no file>
779+
§ -----
780+
c = 3
781+
d = 4"}
782+
);
783+
editor.update_in(cx, |editor, window, cx| {
768784
// Type a character, ensuring we don't even try to interpolate the previous suggestion.
769785
editor.handle_input(" ", window, cx);
770786
assert!(!editor.has_active_edit_prediction());
771-
assert_eq!(
772-
editor.display_text(cx),
773-
"\n\na = 1\nb = 2\n\n\n\nc = 3\nd = 4 \n"
774-
);
775-
assert_eq!(editor.text(cx), "a = 1\nb = 2\n\nc = 3\nd = 4 \n");
776787
});
788+
pretty_assertions::assert_eq!(
789+
editor_content_with_blocks(&editor, cx),
790+
indoc! {"
791+
§ <no file>
792+
§ -----
793+
a = 1
794+
b = 2
795+
§ <no file>
796+
§ -----
797+
c = 3
798+
d = 4\x20"
799+
},
800+
);
777801

778802
// Ensure the new suggestion is displayed when the debounce timeout expires.
779803
executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT);
780-
_ = editor.update(cx, |editor, _, cx| {
804+
_ = editor.update(cx, |editor, _| {
781805
assert!(editor.has_active_edit_prediction());
782-
assert_eq!(
783-
editor.display_text(cx),
784-
"\n\na = 1\nb = 2\n\n\n\nc = 3\nd = 4 + c\n"
785-
);
786-
assert_eq!(editor.text(cx), "a = 1\nb = 2\n\nc = 3\nd = 4 \n");
787806
});
807+
assert_eq!(
808+
editor_content_with_blocks(&editor, cx),
809+
indoc! {"
810+
§ <no file>
811+
§ -----
812+
a = 1
813+
b = 2
814+
§ <no file>
815+
§ -----
816+
c = 3
817+
d = 4 + c"}
818+
);
788819
}
789820

790821
#[gpui::test]
@@ -947,14 +978,18 @@ mod tests {
947978

948979
let multibuffer = cx.new(|cx| {
949980
let mut multibuffer = MultiBuffer::new(language::Capability::ReadWrite);
950-
multibuffer.push_excerpts(
981+
multibuffer.set_excerpts_for_path(
982+
PathKey::sorted(0),
951983
private_buffer.clone(),
952-
[ExcerptRange::new(Point::new(0, 0)..Point::new(1, 0))],
984+
[Point::new(0, 0)..Point::new(1, 0)],
985+
0,
953986
cx,
954987
);
955-
multibuffer.push_excerpts(
988+
multibuffer.set_excerpts_for_path(
989+
PathKey::sorted(1),
956990
public_buffer.clone(),
957-
[ExcerptRange::new(Point::new(0, 0)..Point::new(6, 0))],
991+
[Point::new(0, 0)..Point::new(6, 0)],
992+
0,
958993
cx,
959994
);
960995
multibuffer

crates/debugger_ui/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ settings.workspace = true
6464
sysinfo.workspace = true
6565
task.workspace = true
6666
tasks_ui.workspace = true
67-
telemetry.workspace = true
6867
terminal_view.workspace = true
6968
text.workspace = true
7069
theme.workspace = true

crates/debugger_ui/src/debugger_ui.rs

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ use project::debugger::{self, breakpoint_store::SourceBreakpoint, session::Threa
88
use schemars::JsonSchema;
99
use serde::Deserialize;
1010
use session::DebugSession;
11-
use stack_trace_view::StackTraceView;
11+
1212
use tasks_ui::{Spawn, TaskOverrides};
1313
use ui::{FluentBuilder, InteractiveElement};
1414
use util::maybe;
15-
use workspace::{ItemHandle, ShutdownDebugAdapters, Workspace};
15+
use workspace::{ShutdownDebugAdapters, Workspace};
1616
use zed_actions::debug_panel::{Toggle, ToggleFocus};
1717

1818
pub mod attach_modal;
@@ -21,7 +21,6 @@ mod dropdown_menus;
2121
mod new_process_modal;
2222
mod persistence;
2323
pub(crate) mod session;
24-
mod stack_trace_view;
2524

2625
#[cfg(any(test, feature = "test-support"))]
2726
pub mod tests;
@@ -70,8 +69,6 @@ actions!(
7069
FocusLoadedSources,
7170
/// Focuses on the terminal panel.
7271
FocusTerminal,
73-
/// Shows the stack trace for the current thread.
74-
ShowStackTrace,
7572
/// Toggles the thread picker dropdown.
7673
ToggleThreadPicker,
7774
/// Toggles the session picker dropdown.
@@ -207,39 +204,6 @@ pub fn init(cx: &mut App) {
207204
.ok();
208205
}
209206
})
210-
.on_action(cx.listener(
211-
|workspace, _: &ShowStackTrace, window, cx| {
212-
let Some(debug_panel) = workspace.panel::<DebugPanel>(cx) else {
213-
return;
214-
};
215-
216-
if let Some(existing) = workspace.item_of_type::<StackTraceView>(cx) {
217-
let is_active = workspace
218-
.active_item(cx)
219-
.is_some_and(|item| item.item_id() == existing.item_id());
220-
workspace.activate_item(&existing, true, !is_active, window, cx);
221-
} else {
222-
let Some(active_session) = debug_panel.read(cx).active_session()
223-
else {
224-
return;
225-
};
226-
227-
let project = workspace.project();
228-
229-
let stack_trace_view = active_session.update(cx, |session, cx| {
230-
session.stack_trace_view(project, window, cx).clone()
231-
});
232-
233-
workspace.add_item_to_active_pane(
234-
Box::new(stack_trace_view),
235-
None,
236-
true,
237-
window,
238-
cx,
239-
);
240-
}
241-
},
242-
))
243207
})
244208
.when(supports_detach, |div| {
245209
let active_item = active_item.clone();

0 commit comments

Comments
 (0)