mirror of
https://github.com/zed-industries/zed.git
synced 2026-12-04 08:43:21 +01:00
editor: Remove dead code and redundant checks (#67217)
## Summary Removes unused code and redundant work. No behavior changes. - Removes about 20 unused items. Examples: `HunkAddedColor` and `HunkRemovedColor`, `FoldStatus`, `restore_diff_hunks_in_ranges`, and two `EditorTestContext` helpers. - Nothing called `disable_indent_guides_for_buffer`, so `buffers_with_disabled_indent_guides` was always empty. Removes it, and the lookup that ran for every indent guide. - `Autoscroll::bottom_relative` was the only constructor of `AutoscrollStrategy::BottomRelative`. Removes both. - `SplitEditorState::left_ratio` and `cached_width` were written but never read. - Removes `cx.notify()` after `remove_blocks`, `toggle_git_blame_inline_internal`, `request_autoscroll`, `highlight_background` and `select_entry`, which always notify. - Removes redundant checks and repeated work: - an `edits.is_empty()` early return, already covered by the `edits.first()` let-else that follows it - an `is_empty` check before `CreaseMap::remove` - a re-check of an `Option` in hover popovers - a second identical `anchor_after` call - a second identical buffer snapshot - `multi_buffer`: removes `BufferOffsetUtf16`, `should_expand_up`, `should_expand_down`, `path_for_anchor`, unused lifetimes, and a `cfg` that the enclosing impl already applies. ## Testing - `./script/clippy` - `cargo test -p editor -p multi_buffer -p outline_panel` ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - N/A
This commit is contained in:
1 parent
4e2c957a6d
commit
7279c76ef7
27 files changed
+60
-347
No files matched your search
@@ -64,15 +64,6 @@ impl Editor {
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn disable_indent_guides_for_buffer(
|
||||
&mut self,
|
||||
buffer_id: BufferId,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
self.buffers_with_disabled_indent_guides.insert(buffer_id);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn toggle_line_numbers(
|
||||
&mut self,
|
||||
_: &ToggleLineNumbers,
|
||||
@@ -118,11 +109,6 @@ impl Editor {
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn set_show_horizontal_scrollbar(&mut self, show: bool, cx: &mut Context<Self>) {
|
||||
self.show_scrollbars.horizontal = show;
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn set_minimap_visibility(
|
||||
&mut self,
|
||||
minimap_visibility: MinimapVisibility,
|
||||
@@ -355,11 +341,6 @@ impl Editor {
|
||||
self.show_indent_guides
|
||||
}
|
||||
|
||||
pub(super) fn has_indent_guides_disabled_for_buffer(&self, buffer_id: BufferId) -> bool {
|
||||
self.buffers_with_disabled_indent_guides
|
||||
.contains(&buffer_id)
|
||||
}
|
||||
|
||||
pub(super) fn toggle_relative_line_numbers(
|
||||
&mut self,
|
||||
_: &ToggleRelativeLineNumbers,
|
||||
|
||||
@@ -142,12 +142,6 @@ pub(crate) use tab_map::TabPoint;
|
||||
use tab_map::{TabPointCursor, TabSnapshot};
|
||||
use wrap_map::{WrapMap, WrapPatch, WrapPointCursor};
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum FoldStatus {
|
||||
Folded,
|
||||
Foldable,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct NavigationOverlayKey(TypeId);
|
||||
|
||||
@@ -960,9 +954,7 @@ impl DisplayMap {
|
||||
.lsp_folding_crease_ids
|
||||
.remove(&buffer_id)
|
||||
.unwrap_or_default();
|
||||
if !old_ids.is_empty() {
|
||||
self.crease_map.remove(old_ids, &snapshot);
|
||||
}
|
||||
self.crease_map.remove(old_ids, &snapshot);
|
||||
|
||||
if ranges.is_empty() {
|
||||
return;
|
||||
@@ -1808,11 +1800,6 @@ impl DisplaySnapshot {
|
||||
.to_offset(self.display_point_to_inlay_point(point, bias))
|
||||
}
|
||||
|
||||
pub fn anchor_to_inlay_offset(&self, anchor: Anchor) -> InlayOffset {
|
||||
self.inlay_snapshot()
|
||||
.to_inlay_offset(anchor.to_offset(self.buffer_snapshot()))
|
||||
}
|
||||
|
||||
pub fn display_point_to_anchor(&self, point: DisplayPoint, bias: Bias) -> Anchor {
|
||||
self.buffer_snapshot()
|
||||
.anchor_at(point.to_offset(self, bias), bias)
|
||||
|
||||
@@ -4367,7 +4367,7 @@ mod tests {
|
||||
// so we special case row 0 to assume a leading '\n'.
|
||||
//
|
||||
// Linehood is the birthright of strings.
|
||||
let input_text_lines = input_text.split('\n').enumerate().peekable();
|
||||
let input_text_lines = input_text.split('\n').enumerate();
|
||||
let mut block_row = 0;
|
||||
for (wrap_row, input_line) in input_text_lines {
|
||||
let wrap_row = WrapRow(wrap_row as u32);
|
||||
|
||||
@@ -4,7 +4,7 @@ use super::{
|
||||
};
|
||||
|
||||
use language::{LanguageAwareStyling, Point};
|
||||
use multi_buffer::{MultiBufferRow, MultiBufferSnapshot};
|
||||
use multi_buffer::MultiBufferSnapshot;
|
||||
use std::{cmp, num::NonZeroU32, ops::Range};
|
||||
use sum_tree::Bias;
|
||||
|
||||
@@ -413,11 +413,6 @@ impl TabSnapshot {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn buffer_row_to_tab_row(&self, buffer_row: MultiBufferRow) -> u32 {
|
||||
self.point_to_tab_point(Point::new(buffer_row.0, 0), Bias::Left)
|
||||
.row()
|
||||
}
|
||||
|
||||
#[ztracing::instrument(skip_all)]
|
||||
pub fn point_to_tab_point(&self, point: Point, bias: Bias) -> TabPoint {
|
||||
let inlay_point = self.fold_snapshot.inlay_snapshot.to_inlay_point(point);
|
||||
@@ -1243,8 +1238,6 @@ mod tests {
|
||||
#[gpui::test]
|
||||
fn test_to_fold_point_panic_reproduction(cx: &mut gpui::App) {
|
||||
// This test reproduces a specific panic where to_fold_point returns incorrect results
|
||||
let _text = "use macro_rules_attribute::apply;\nuse serde_json::Value;\nuse smol::{\n io::AsyncReadExt,\n process::{Command, Stdio},\n};\nuse smol_macros::main;\nuse std::io;\n\nfn test_random() {\n // Generate a random value\n let random_value = std::time::SystemTime::now()\n .duration_since(std::time::UNIX_EPOCH)\n .unwrap()\n .as_secs()\n % 100;\n\n // Create some complex nested data structures\n let mut vector = Vec::new();\n for i in 0..random_value {\n vector.push(i);\n }\n ";
|
||||
|
||||
let text = "γ\tw⭐\n🍐🍗 \t";
|
||||
let buffer = MultiBuffer::build_simple(text, cx);
|
||||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
|
||||
@@ -924,9 +924,6 @@ impl Editor {
|
||||
))
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
if edits.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let cursor_position = predicted_cursor_position.and_then(|predicted| {
|
||||
let anchor = multibuffer.anchor_in_excerpt(predicted.anchor)?;
|
||||
|
||||
@@ -1815,7 +1815,7 @@ impl EditPredictionDelegate for FakeEditPredictionDelegate {
|
||||
self.completion.take();
|
||||
}
|
||||
|
||||
fn suggest<'a>(
|
||||
fn suggest(
|
||||
&mut self,
|
||||
_buffer: &gpui::Entity<language::Buffer>,
|
||||
_cursor_position: language::Anchor,
|
||||
@@ -1893,7 +1893,7 @@ impl EditPredictionDelegate for FakeNonZedEditPredictionDelegate {
|
||||
self.completion.take();
|
||||
}
|
||||
|
||||
fn suggest<'a>(
|
||||
fn suggest(
|
||||
&mut self,
|
||||
_buffer: &gpui::Entity<language::Buffer>,
|
||||
_cursor_position: language::Anchor,
|
||||
|
||||
@@ -346,9 +346,6 @@ pub enum ConflictsTheirs {}
|
||||
pub enum ConflictsOursMarker {}
|
||||
pub enum ConflictsTheirsMarker {}
|
||||
|
||||
pub struct HunkAddedColor;
|
||||
pub struct HunkRemovedColor;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub enum Navigated {
|
||||
Yes,
|
||||
@@ -1050,7 +1047,6 @@ pub struct Editor {
|
||||
show_diff_review_button: bool,
|
||||
show_wrap_guides: Option<bool>,
|
||||
show_indent_guides: Option<bool>,
|
||||
buffers_with_disabled_indent_guides: HashSet<BufferId>,
|
||||
highlight_order: usize,
|
||||
highlighted_rows: TypeIdHashMap<Vec<RowHighlight>>,
|
||||
background_highlights: HashMap<HighlightKey, BackgroundHighlight>,
|
||||
@@ -1921,8 +1917,6 @@ impl Editor {
|
||||
.clone_state(&self.scroll_manager, &my_snapshot, &clone_snapshot, cx);
|
||||
clone.searchable = self.searchable;
|
||||
clone.read_only = self.read_only;
|
||||
clone.buffers_with_disabled_indent_guides =
|
||||
self.buffers_with_disabled_indent_guides.clone();
|
||||
clone.enable_mouse_wheel_zoom = self.enable_mouse_wheel_zoom;
|
||||
clone.enable_lsp_data = self.enable_lsp_data;
|
||||
clone.needs_initial_data_update = self.enable_lsp_data;
|
||||
@@ -2440,7 +2434,6 @@ impl Editor {
|
||||
show_diff_review_button: false,
|
||||
show_wrap_guides: None,
|
||||
show_indent_guides,
|
||||
buffers_with_disabled_indent_guides: HashSet::default(),
|
||||
highlight_order: 0,
|
||||
highlighted_rows: Default::default(),
|
||||
background_highlights: HashMap::default(),
|
||||
@@ -3852,7 +3845,6 @@ impl Editor {
|
||||
|_, theme| theme.colors().editor_document_highlight_write_background,
|
||||
cx,
|
||||
);
|
||||
cx.notify();
|
||||
})
|
||||
.log_err();
|
||||
}
|
||||
@@ -5174,11 +5166,10 @@ impl Editor {
|
||||
let autoclose_enabled =
|
||||
self.use_autoclose && snapshot_settings.use_autoclose;
|
||||
if autoclose_enabled {
|
||||
let start = snapshot.anchor_after(selection_head);
|
||||
let end = snapshot.anchor_after(selection_head);
|
||||
let anchor = snapshot.anchor_after(selection_head);
|
||||
self.autoclose_regions.push(AutocloseRegion {
|
||||
selection_id: selection.id,
|
||||
range: start..end,
|
||||
range: anchor..anchor,
|
||||
pair,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18681,7 +18681,7 @@ async fn test_snippet_placeholder_choices(cx: &mut TestAppContext) {
|
||||
let buffer = cx.update(|cx| MultiBuffer::build_simple(&text, cx));
|
||||
let (editor, cx) = cx.add_window_view(|window, cx| build_editor(buffer, window, cx));
|
||||
|
||||
_ = editor.update_in(cx, |editor, window, cx| {
|
||||
editor.update_in(cx, |editor, window, cx| {
|
||||
let snippet = Snippet::parse("type ${1|,i32,u32|} = $2").unwrap();
|
||||
|
||||
editor
|
||||
@@ -18734,7 +18734,7 @@ async fn test_snippet_choices_menu_survives_completion_refresh(cx: &mut TestAppC
|
||||
let buffer = cx.update(|cx| MultiBuffer::build_simple(&text, cx));
|
||||
let (editor, cx) = cx.add_window_view(|window, cx| build_editor(buffer, window, cx));
|
||||
|
||||
_ = editor.update_in(cx, |editor, window, cx| {
|
||||
editor.update_in(cx, |editor, window, cx| {
|
||||
let snippet = Snippet::parse("type ${1|i32,u32|} = $2").unwrap();
|
||||
|
||||
editor
|
||||
@@ -18789,7 +18789,7 @@ async fn test_snippet_tabstop_navigation_with_placeholders(cx: &mut TestAppConte
|
||||
let buffer = cx.update(|cx| MultiBuffer::build_simple(&text, cx));
|
||||
let (editor, cx) = cx.add_window_view(|window, cx| build_editor(buffer, window, cx));
|
||||
|
||||
_ = editor.update_in(cx, |editor, window, cx| {
|
||||
editor.update_in(cx, |editor, window, cx| {
|
||||
let snippet = Snippet::parse("type ${1|,i32,u32|} = $2; $3").unwrap();
|
||||
|
||||
editor
|
||||
@@ -18853,7 +18853,7 @@ async fn test_snippet_tabstop_navigation_with_placeholders(cx: &mut TestAppConte
|
||||
);
|
||||
});
|
||||
|
||||
_ = editor.update_in(cx, |editor, window, cx| {
|
||||
editor.update_in(cx, |editor, window, cx| {
|
||||
editor.select_all(&SelectAll, window, cx);
|
||||
editor.backspace(&Backspace, window, cx);
|
||||
|
||||
@@ -22668,9 +22668,7 @@ async fn test_handle_input_for_show_signature_help_auto_signature_help_true(
|
||||
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
signature_help_provider: Some(lsp::SignatureHelpOptions {
|
||||
..Default::default()
|
||||
}),
|
||||
signature_help_provider: Some(lsp::SignatureHelpOptions::default()),
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
@@ -22988,9 +22986,7 @@ async fn test_handle_input_with_different_show_signature_settings(cx: &mut TestA
|
||||
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
signature_help_provider: Some(lsp::SignatureHelpOptions {
|
||||
..Default::default()
|
||||
}),
|
||||
signature_help_provider: Some(lsp::SignatureHelpOptions::default()),
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
@@ -23200,9 +23196,7 @@ async fn test_signature_help(cx: &mut TestAppContext) {
|
||||
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
signature_help_provider: Some(lsp::SignatureHelpOptions {
|
||||
..Default::default()
|
||||
}),
|
||||
signature_help_provider: Some(lsp::SignatureHelpOptions::default()),
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
@@ -23458,9 +23452,7 @@ async fn test_signature_help_multiple_signatures(cx: &mut TestAppContext) {
|
||||
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
signature_help_provider: Some(lsp::SignatureHelpOptions {
|
||||
..Default::default()
|
||||
}),
|
||||
signature_help_provider: Some(lsp::SignatureHelpOptions::default()),
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
@@ -26197,9 +26189,7 @@ async fn test_as_is_completions(cx: &mut TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
completion_provider: Some(lsp::CompletionOptions {
|
||||
..Default::default()
|
||||
}),
|
||||
completion_provider: Some(lsp::CompletionOptions::default()),
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
@@ -26250,9 +26240,7 @@ async fn test_panic_during_c_completions(cx: &mut TestAppContext) {
|
||||
let mut cx = EditorLspTestContext::new(
|
||||
language,
|
||||
lsp::ServerCapabilities {
|
||||
completion_provider: Some(lsp::CompletionOptions {
|
||||
..lsp::CompletionOptions::default()
|
||||
}),
|
||||
completion_provider: Some(lsp::CompletionOptions::default()),
|
||||
..lsp::ServerCapabilities::default()
|
||||
},
|
||||
cx,
|
||||
@@ -41486,12 +41474,7 @@ async fn test_invisible_worktree_servers(cx: &mut TestAppContext) {
|
||||
let project = Project::test(fs, [path!("/root/a").as_ref()], cx).await;
|
||||
let language_registry = project.read_with(cx, |project, _| project.languages().clone());
|
||||
language_registry.add(rust_lang());
|
||||
let _fake_servers = language_registry.register_fake_lsp(
|
||||
"Rust",
|
||||
FakeLspAdapter {
|
||||
..FakeLspAdapter::default()
|
||||
},
|
||||
);
|
||||
let _fake_servers = language_registry.register_fake_lsp("Rust", FakeLspAdapter::default());
|
||||
let (multi_workspace, cx) =
|
||||
cx.add_window_view(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));
|
||||
let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone());
|
||||
@@ -42604,9 +42587,7 @@ async fn test_mixed_completions_with_multi_word_snippet(cx: &mut TestAppContext)
|
||||
init_test(cx, |_| {});
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
completion_provider: Some(lsp::CompletionOptions {
|
||||
..Default::default()
|
||||
}),
|
||||
completion_provider: Some(lsp::CompletionOptions::default()),
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
@@ -44967,12 +44948,7 @@ async fn test_race_in_multibuffer_save(cx: &mut TestAppContext) {
|
||||
let language = rust_lang();
|
||||
let language_registry = project.read_with(cx, |project, _| project.languages().clone());
|
||||
language_registry.add(language.clone());
|
||||
let mut fake_servers = language_registry.register_fake_lsp(
|
||||
"Rust",
|
||||
FakeLspAdapter {
|
||||
..FakeLspAdapter::default()
|
||||
},
|
||||
);
|
||||
let mut fake_servers = language_registry.register_fake_lsp("Rust", FakeLspAdapter::default());
|
||||
|
||||
let buffer1 = project
|
||||
.update(cx, |project, cx| {
|
||||
|
||||
@@ -11048,13 +11048,6 @@ impl CursorLayout {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bounding_rect(&self, origin: gpui::Point<Pixels>) -> Bounds<Pixels> {
|
||||
Bounds {
|
||||
origin: self.origin + origin,
|
||||
size: size(self.block_width, self.line_height),
|
||||
}
|
||||
}
|
||||
|
||||
fn bounds(&self, origin: gpui::Point<Pixels>) -> Bounds<Pixels> {
|
||||
match self.shape {
|
||||
CursorShape::Bar => Bounds {
|
||||
|
||||
@@ -935,11 +935,6 @@ impl EditorElement {
|
||||
} else if cfg!(any(target_os = "linux", target_os = "freebsd"))
|
||||
&& event.button == MouseButton::Middle
|
||||
{
|
||||
#[allow(
|
||||
clippy::collapsible_if,
|
||||
clippy::needless_return,
|
||||
reason = "The cfg-block below makes this a false positive"
|
||||
)]
|
||||
if !text_hitbox.is_hovered(window) || editor.read_only(cx) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -444,7 +444,6 @@ impl Editor {
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
self.toggle_git_blame_inline_internal(true, window, cx);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
/// Hides the inline blame popover element, in case it's already visible, or
|
||||
@@ -1118,7 +1117,6 @@ impl Editor {
|
||||
.map(|overlay| overlay.block_id)
|
||||
.collect();
|
||||
self.remove_blocks(block_ids, None, cx);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
/// Action handler for SubmitDiffReviewComment.
|
||||
@@ -2102,17 +2100,6 @@ impl Editor {
|
||||
.detach_and_log_err(cx);
|
||||
}
|
||||
|
||||
pub fn restore_diff_hunks_in_ranges(
|
||||
&mut self,
|
||||
ranges: Vec<Range<Anchor>>,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let snapshot = self.buffer.read(cx).snapshot(cx);
|
||||
let hunks = self.diff_hunks_in_ranges(&ranges, &snapshot).collect();
|
||||
self.apply_restore(hunks, window, cx);
|
||||
}
|
||||
|
||||
fn toggle_diff_hunks_in_ranges(
|
||||
&mut self,
|
||||
ranges: Vec<Range<Anchor>>,
|
||||
@@ -2433,7 +2420,6 @@ impl Editor {
|
||||
|
||||
if !block_ids_to_remove.is_empty() {
|
||||
self.remove_blocks(block_ids_to_remove, None, cx);
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2464,7 +2450,6 @@ impl Editor {
|
||||
};
|
||||
|
||||
// Calculate new height
|
||||
let snapshot = self.buffer.read(cx).snapshot(cx);
|
||||
let new_height = self.calculate_overlay_height(hunk_key, comments_expanded, &snapshot);
|
||||
|
||||
// Update the block height using resize_blocks (avoids flicker)
|
||||
|
||||
@@ -3322,13 +3322,7 @@ mod tests {
|
||||
#[gpui::test]
|
||||
async fn test_urls(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
)
|
||||
.await;
|
||||
let mut cx = EditorLspTestContext::new_rust(lsp::ServerCapabilities::default(), cx).await;
|
||||
|
||||
cx.set_state(indoc! {"
|
||||
Let's test a [complex](https://zed.dev/channel/had-(oops)) caseˇ.
|
||||
@@ -3511,13 +3505,7 @@ mod tests {
|
||||
#[gpui::test]
|
||||
async fn test_hover_preconditions(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
)
|
||||
.await;
|
||||
let mut cx = EditorLspTestContext::new_rust(lsp::ServerCapabilities::default(), cx).await;
|
||||
|
||||
macro_rules! assert_no_highlight {
|
||||
($cx:expr) => {
|
||||
@@ -3565,13 +3553,7 @@ mod tests {
|
||||
#[gpui::test]
|
||||
async fn test_urls_at_beginning_of_buffer(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
)
|
||||
.await;
|
||||
let mut cx = EditorLspTestContext::new_rust(lsp::ServerCapabilities::default(), cx).await;
|
||||
|
||||
cx.set_state(indoc! {"https://zed.dev/releases is a cool ˇwebpage."});
|
||||
|
||||
@@ -3592,13 +3574,7 @@ mod tests {
|
||||
#[gpui::test]
|
||||
async fn test_urls_at_end_of_buffer(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
)
|
||||
.await;
|
||||
let mut cx = EditorLspTestContext::new_rust(lsp::ServerCapabilities::default(), cx).await;
|
||||
|
||||
cx.set_state(indoc! {"A cool ˇwebpage is https://zed.dev/releases"});
|
||||
|
||||
@@ -3715,13 +3691,7 @@ mod tests {
|
||||
#[gpui::test]
|
||||
async fn test_surrounding_filename(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
)
|
||||
.await;
|
||||
let mut cx = EditorLspTestContext::new_rust(lsp::ServerCapabilities::default(), cx).await;
|
||||
|
||||
let test_cases = [
|
||||
("file ˇ name", None),
|
||||
@@ -3799,13 +3769,7 @@ mod tests {
|
||||
#[gpui::test]
|
||||
async fn test_hover_filenames(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
)
|
||||
.await;
|
||||
let mut cx = EditorLspTestContext::new_rust(lsp::ServerCapabilities::default(), cx).await;
|
||||
|
||||
// Insert a new file
|
||||
let fs = cx.update_workspace(|workspace, _, cx| workspace.project().read(cx).fs().clone());
|
||||
@@ -3969,13 +3933,7 @@ Sentence ending file2.rs.
|
||||
#[gpui::test]
|
||||
async fn test_hover_filename_with_row_column(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
)
|
||||
.await;
|
||||
let mut cx = EditorLspTestContext::new_rust(lsp::ServerCapabilities::default(), cx).await;
|
||||
|
||||
// Insert a new file with multiple lines
|
||||
let fs = cx.update_workspace(|workspace, _, cx| workspace.project().read(cx).fs().clone());
|
||||
@@ -4048,13 +4006,7 @@ Sentence ending file2.rs.
|
||||
#[gpui::test]
|
||||
async fn test_hover_filename_with_row_only(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
)
|
||||
.await;
|
||||
let mut cx = EditorLspTestContext::new_rust(lsp::ServerCapabilities::default(), cx).await;
|
||||
|
||||
let fs = cx.update_workspace(|workspace, _, cx| workspace.project().read(cx).fs().clone());
|
||||
fs.as_fake()
|
||||
@@ -4109,13 +4061,7 @@ Sentence ending file2.rs.
|
||||
#[gpui::test]
|
||||
async fn test_hover_filename_with_non_numeric_suffix(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
)
|
||||
.await;
|
||||
let mut cx = EditorLspTestContext::new_rust(lsp::ServerCapabilities::default(), cx).await;
|
||||
|
||||
let fs = cx.update_workspace(|workspace, _, cx| workspace.project().read(cx).fs().clone());
|
||||
fs.as_fake()
|
||||
@@ -4167,13 +4113,7 @@ Sentence ending file2.rs.
|
||||
#[gpui::test]
|
||||
async fn test_hover_markdown_link_with_row_column(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
)
|
||||
.await;
|
||||
let mut cx = EditorLspTestContext::new_rust(lsp::ServerCapabilities::default(), cx).await;
|
||||
|
||||
let fs = cx.update_workspace(|workspace, _, cx| workspace.project().read(cx).fs().clone());
|
||||
fs.as_fake()
|
||||
@@ -4245,13 +4185,7 @@ Sentence ending file2.rs.
|
||||
#[gpui::test]
|
||||
async fn test_hover_directories(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
)
|
||||
.await;
|
||||
let mut cx = EditorLspTestContext::new_rust(lsp::ServerCapabilities::default(), cx).await;
|
||||
|
||||
// Insert a new file
|
||||
let fs = cx.update_workspace(|workspace, _, cx| workspace.project().read(cx).fs().clone());
|
||||
@@ -4290,13 +4224,7 @@ Sentence ending file2.rs.
|
||||
#[gpui::test]
|
||||
async fn test_hover_unicode(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx, |_| {});
|
||||
let mut cx = EditorLspTestContext::new_rust(
|
||||
lsp::ServerCapabilities {
|
||||
..Default::default()
|
||||
},
|
||||
cx,
|
||||
)
|
||||
.await;
|
||||
let mut cx = EditorLspTestContext::new_rust(lsp::ServerCapabilities::default(), cx).await;
|
||||
|
||||
cx.set_state(indoc! {"
|
||||
You can't open ˇ\"🤩\" because it's an emoji.
|
||||
|
||||
@@ -556,27 +556,23 @@ fn show_hover(
|
||||
(range, Some(fallback_state))
|
||||
});
|
||||
|
||||
let parsed_content =
|
||||
parse_blocks(&blocks, language_registry.as_ref(), language, cx);
|
||||
if parsed_content.is_none() {
|
||||
let Some(parsed_content) =
|
||||
parse_blocks(&blocks, language_registry.as_ref(), language, cx)
|
||||
else {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let scroll_handle = ScrollHandle::new();
|
||||
hover_highlights.push(range.clone());
|
||||
let subscriptions = this
|
||||
.update(cx, |_, cx| {
|
||||
let mut subscriptions = Vec::new();
|
||||
if let Some(parsed_content) = parsed_content.as_ref() {
|
||||
subscriptions.push(cx.observe(parsed_content, |_, _, cx| cx.notify()));
|
||||
}
|
||||
subscriptions
|
||||
vec![cx.observe(&parsed_content, |_, _, cx| cx.notify())]
|
||||
})
|
||||
.ok()
|
||||
.unwrap_or_default();
|
||||
info_popovers.push(InfoPopover {
|
||||
symbol_range: RangeInEditor::Text(range),
|
||||
fallback_state,
|
||||
parsed_content,
|
||||
parsed_content: Some(parsed_content),
|
||||
debugger_hover: None,
|
||||
scroll_handle,
|
||||
keyboard_grace: Rc::new(RefCell::new(ignore_timeout)),
|
||||
|
||||
@@ -160,7 +160,7 @@ pub fn indent_guides_in_range(
|
||||
let end_anchor = snapshot.buffer_snapshot().anchor_after(end_offset);
|
||||
|
||||
let mut fold_ranges = Vec::<Range<Point>>::new();
|
||||
let folds = snapshot.folds_in_range(start_offset..end_offset).peekable();
|
||||
let folds = snapshot.folds_in_range(start_offset..end_offset);
|
||||
for fold in folds {
|
||||
let start = fold.range.start.to_point(&snapshot.buffer_snapshot());
|
||||
let end = fold.range.end.to_point(&snapshot.buffer_snapshot());
|
||||
@@ -177,10 +177,6 @@ pub fn indent_guides_in_range(
|
||||
.buffer_snapshot()
|
||||
.indent_guides_in_range(start_anchor..end_anchor, ignore_disabled_for_language, cx)
|
||||
.filter(|indent_guide| {
|
||||
if editor.has_indent_guides_disabled_for_buffer(indent_guide.buffer_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if editor.is_buffer_folded(indent_guide.buffer_id, cx) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -187,16 +187,6 @@ impl Editor {
|
||||
self.inline_value_cache.enabled
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub fn inline_value_inlays(&self, cx: &gpui::App) -> Vec<Inlay> {
|
||||
self.display_map
|
||||
.read(cx)
|
||||
.current_inlays()
|
||||
.filter(|inlay| matches!(inlay.id, InlayId::DebuggerValue(_)))
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub fn all_inlays(&self, cx: &gpui::App) -> Vec<Inlay> {
|
||||
self.display_map
|
||||
|
||||
@@ -960,7 +960,7 @@ impl Item for Editor {
|
||||
self.report_editor_event(ReportEditorEvent::Saved { auto_saved: false }, None, cx);
|
||||
}
|
||||
|
||||
let buffers = self.buffer().clone().read(cx).all_buffers();
|
||||
let buffers = self.buffer().read(cx).all_buffers();
|
||||
let buffers = buffers
|
||||
.into_iter()
|
||||
.map(|handle| handle.read(cx).base_buffer().unwrap_or(handle.clone()))
|
||||
|
||||
@@ -190,18 +190,6 @@ impl ScrollManager {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_native_display_map_id(
|
||||
&mut self,
|
||||
display_map_id: EntityId,
|
||||
cx: &mut Context<Editor>,
|
||||
) {
|
||||
self.anchor.update(cx, |shared, _| {
|
||||
if shared.display_map_id.is_none() {
|
||||
shared.display_map_id = Some(display_map_id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
pub fn clone_state(
|
||||
&mut self,
|
||||
other: &Self,
|
||||
|
||||
@@ -64,12 +64,6 @@ impl Autoscroll {
|
||||
Self::Strategy(AutoscrollStrategy::Top, None)
|
||||
}
|
||||
|
||||
/// Scrolls so that the newest cursor is the given offset (in display rows)
|
||||
/// from the bottom of the viewport.
|
||||
pub fn bottom_relative(offset: ScrollOffset) -> Self {
|
||||
Self::Strategy(AutoscrollStrategy::BottomRelative(offset), None)
|
||||
}
|
||||
|
||||
/// Scrolls so that the newest cursor is at the bottom.
|
||||
pub fn bottom() -> Self {
|
||||
Self::Strategy(AutoscrollStrategy::Bottom, None)
|
||||
@@ -106,7 +100,6 @@ pub enum AutoscrollStrategy {
|
||||
Top,
|
||||
Bottom,
|
||||
TopRelative(ScrollOffset),
|
||||
BottomRelative(ScrollOffset),
|
||||
}
|
||||
|
||||
impl Eq for AutoscrollStrategy {}
|
||||
@@ -282,10 +275,6 @@ impl Editor {
|
||||
scroll_position.y = target_top - lines as ScrollOffset;
|
||||
self.set_scroll_position_internal(scroll_position, local, true, window, cx)
|
||||
}
|
||||
AutoscrollStrategy::BottomRelative(lines) => {
|
||||
scroll_position.y = target_bottom + lines as ScrollOffset;
|
||||
self.set_scroll_position_internal(scroll_position, local, true, window, cx)
|
||||
}
|
||||
};
|
||||
|
||||
self.scroll_manager.last_autoscroll = Some((
|
||||
|
||||
@@ -189,7 +189,6 @@ impl Editor {
|
||||
});
|
||||
});
|
||||
self.request_autoscroll(Autoscroll::newest(), cx);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn select_to_end(&mut self, _: &SelectToEnd, window: &mut Window, cx: &mut Context<Self>) {
|
||||
|
||||
@@ -30,21 +30,16 @@ const RESIZE_HANDLE_WIDTH: f32 = 8.0;
|
||||
struct DraggedSplitHandle;
|
||||
|
||||
pub struct SplitEditorState {
|
||||
left_ratio: f32,
|
||||
visible_left_ratio: f32,
|
||||
cached_width: Pixels,
|
||||
}
|
||||
|
||||
impl SplitEditorState {
|
||||
pub fn new(_cx: &mut App) -> Self {
|
||||
Self {
|
||||
left_ratio: 0.5,
|
||||
visible_left_ratio: 0.5,
|
||||
cached_width: px(0.),
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::misnamed_getters)]
|
||||
pub fn left_ratio(&self) -> f32 {
|
||||
self.visible_left_ratio
|
||||
}
|
||||
@@ -63,10 +58,6 @@ impl SplitEditorState {
|
||||
let bounds = drag_event.bounds;
|
||||
let bounds_width = bounds.right() - bounds.left();
|
||||
|
||||
if bounds_width > px(0.) {
|
||||
self.cached_width = bounds_width;
|
||||
}
|
||||
|
||||
let min_ratio = 0.1;
|
||||
let max_ratio = 0.9;
|
||||
|
||||
@@ -74,12 +65,7 @@ impl SplitEditorState {
|
||||
self.visible_left_ratio = new_ratio.clamp(min_ratio, max_ratio);
|
||||
}
|
||||
|
||||
fn commit_ratio(&mut self) {
|
||||
self.left_ratio = self.visible_left_ratio;
|
||||
}
|
||||
|
||||
fn on_double_click(&mut self) {
|
||||
self.left_ratio = 0.5;
|
||||
self.visible_left_ratio = 0.5;
|
||||
}
|
||||
}
|
||||
@@ -168,7 +154,6 @@ impl RenderOnce for SplitEditorView {
|
||||
let resize_handle = render_resize_handle(&self.split_state, separator_color, window, cx);
|
||||
|
||||
let state_for_drag = self.split_state.downgrade();
|
||||
let state_for_drop = self.split_state.downgrade();
|
||||
|
||||
let buffer_headers = SplitBufferHeadersElement::new(
|
||||
lhs_editor.clone(),
|
||||
@@ -202,13 +187,9 @@ impl RenderOnce for SplitEditorView {
|
||||
})
|
||||
.ok();
|
||||
})
|
||||
.on_drop::<DraggedSplitHandle>(move |_, _, cx| {
|
||||
state_for_drop
|
||||
.update(cx, |state, _| {
|
||||
state.commit_ratio();
|
||||
})
|
||||
.ok();
|
||||
})
|
||||
// Registering a drop target ends the drag here; the ratio was
|
||||
// already applied while dragging.
|
||||
.on_drop::<DraggedSplitHandle>(|_, _, _| {})
|
||||
.child(
|
||||
div()
|
||||
.id("split-editor-left")
|
||||
|
||||
@@ -121,7 +121,6 @@ pub fn assert_text_with_selections(
|
||||
assert_eq!(actual, marked_text, "Selections don't match");
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub(crate) fn build_editor(
|
||||
buffer: Entity<MultiBuffer>,
|
||||
window: &mut Window,
|
||||
|
||||
@@ -316,13 +316,6 @@ impl EditorTestContext {
|
||||
})
|
||||
}
|
||||
|
||||
// Returns anchors for the current buffer using `«` and `»`
|
||||
pub fn text_anchor_range(&mut self, marked_text: &str) -> Range<language::Anchor> {
|
||||
let ranges = self.ranges(marked_text);
|
||||
let snapshot = self.buffer_snapshot();
|
||||
snapshot.anchor_before(ranges[0].start)..snapshot.anchor_after(ranges[0].end)
|
||||
}
|
||||
|
||||
pub async fn wait_for_autoindent_applied(&mut self) {
|
||||
if let Some(fut) = self.update_buffer(|buffer, _| buffer.wait_for_autoindent_applied()) {
|
||||
fut.await.ok();
|
||||
@@ -342,14 +335,6 @@ impl EditorTestContext {
|
||||
self.cx.run_until_parked();
|
||||
}
|
||||
|
||||
pub fn clear_index_text(&mut self) {
|
||||
self.cx.run_until_parked();
|
||||
let fs =
|
||||
self.update_editor(|editor, _, cx| editor.project().unwrap().read(cx).fs().as_fake());
|
||||
fs.set_index_for_repo(&Self::root_path().join(".git"), &[]);
|
||||
self.cx.run_until_parked();
|
||||
}
|
||||
|
||||
pub fn set_index_text(&mut self, diff_base: &str) {
|
||||
self.cx.run_until_parked();
|
||||
let fs =
|
||||
|
||||
@@ -285,9 +285,7 @@ impl DivInspector {
|
||||
..
|
||||
} = &self.state
|
||||
{
|
||||
if let Err(err) =
|
||||
self.reset_style_editors(&rust_style_buffer.clone(), &json_style_buffer.clone(), cx)
|
||||
{
|
||||
if let Err(err) = self.reset_style_editors(rust_style_buffer, json_style_buffer, cx) {
|
||||
self.json_style_error = Some(format!("{err}").into());
|
||||
} else {
|
||||
self.json_style_error = None;
|
||||
|
||||
@@ -514,7 +514,7 @@ impl ToOffset for Anchor {
|
||||
}
|
||||
|
||||
impl ToPoint for Anchor {
|
||||
fn to_point<'a>(&self, snapshot: &MultiBufferSnapshot) -> Point {
|
||||
fn to_point(&self, snapshot: &MultiBufferSnapshot) -> Point {
|
||||
self.summary(snapshot)
|
||||
}
|
||||
fn to_point_utf16(&self, snapshot: &MultiBufferSnapshot) -> rope::PointUtf16 {
|
||||
|
||||
@@ -410,9 +410,6 @@ impl Sub<OffsetUtf16> for MultiBufferOffsetUtf16 {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, Default, Eq, Ord, PartialOrd, PartialEq)]
|
||||
pub struct BufferOffsetUtf16(pub OffsetUtf16);
|
||||
|
||||
impl MultiBufferOffset {
|
||||
const ZERO: Self = Self(0);
|
||||
pub fn saturating_sub(self, other: MultiBufferOffset) -> usize {
|
||||
@@ -1271,24 +1268,6 @@ pub enum ExpandExcerptDirection {
|
||||
UpAndDown,
|
||||
}
|
||||
|
||||
impl ExpandExcerptDirection {
|
||||
pub fn should_expand_up(&self) -> bool {
|
||||
match self {
|
||||
ExpandExcerptDirection::Up => true,
|
||||
ExpandExcerptDirection::Down => false,
|
||||
ExpandExcerptDirection::UpAndDown => true,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn should_expand_down(&self) -> bool {
|
||||
match self {
|
||||
ExpandExcerptDirection::Up => false,
|
||||
ExpandExcerptDirection::Down => true,
|
||||
ExpandExcerptDirection::UpAndDown => true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct IndentGuide {
|
||||
pub buffer_id: BufferId,
|
||||
@@ -1461,8 +1440,6 @@ impl MultiBuffer {
|
||||
self.read(cx).has_conflict()
|
||||
}
|
||||
|
||||
// The `is_empty` signature doesn't match what clippy expects
|
||||
#[allow(clippy::len_without_is_empty)]
|
||||
pub fn len(&self, cx: &App) -> MultiBufferOffset {
|
||||
self.read(cx).len()
|
||||
}
|
||||
@@ -6510,7 +6487,7 @@ impl MultiBufferSnapshot {
|
||||
self.lift_buffer_metadata::<MBD, _, _>(range, move |buffer, buffer_range| {
|
||||
Some(
|
||||
buffer
|
||||
.diagnostics_in_range(buffer_range.start..buffer_range.end, false)
|
||||
.diagnostics_in_range(buffer_range, false)
|
||||
.map(|entry| (entry.range, entry.diagnostic)),
|
||||
)
|
||||
})
|
||||
@@ -6537,7 +6514,7 @@ impl MultiBufferSnapshot {
|
||||
self.lift_buffer_metadata::<MBD, _, _>(range, move |buffer, buffer_range| {
|
||||
Some(
|
||||
buffer
|
||||
.diagnostics_in_range(buffer_range.start..buffer_range.end, false)
|
||||
.diagnostics_in_range(buffer_range, false)
|
||||
.map(|entry| (entry.range, entry.diagnostic)),
|
||||
)
|
||||
})
|
||||
@@ -6681,11 +6658,6 @@ impl MultiBufferSnapshot {
|
||||
self.path_keys.get_index(anchor.path.0 as usize)
|
||||
}
|
||||
|
||||
pub fn path_for_anchor(&self, anchor: ExcerptAnchor) -> &PathKey {
|
||||
self.try_path_for_anchor(anchor)
|
||||
.expect("invalid anchor: path was never added to multibuffer")
|
||||
}
|
||||
|
||||
/// Returns the excerpt containing range and its offset start within the multibuffer or none if `range` spans multiple excerpts
|
||||
pub fn excerpt_containing<T: ToOffset>(
|
||||
&self,
|
||||
@@ -7056,7 +7028,6 @@ impl MultiBufferSnapshot {
|
||||
start..end
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
fn check_invariants(&self) {
|
||||
let excerpts = self.excerpts.items(());
|
||||
|
||||
@@ -8446,7 +8417,7 @@ impl<'a> Iterator for ExcerptChunks<'a> {
|
||||
}
|
||||
|
||||
impl ToOffset for Point {
|
||||
fn to_offset<'a>(&self, snapshot: &MultiBufferSnapshot) -> MultiBufferOffset {
|
||||
fn to_offset(&self, snapshot: &MultiBufferSnapshot) -> MultiBufferOffset {
|
||||
snapshot.point_to_offset(*self)
|
||||
}
|
||||
fn to_offset_utf16(&self, snapshot: &MultiBufferSnapshot) -> MultiBufferOffsetUtf16 {
|
||||
@@ -8456,7 +8427,7 @@ impl ToOffset for Point {
|
||||
|
||||
impl ToOffset for MultiBufferOffset {
|
||||
#[track_caller]
|
||||
fn to_offset<'a>(&self, snapshot: &MultiBufferSnapshot) -> MultiBufferOffset {
|
||||
fn to_offset(&self, snapshot: &MultiBufferSnapshot) -> MultiBufferOffset {
|
||||
assert!(
|
||||
*self <= snapshot.len(),
|
||||
"offset {} is greater than the snapshot.len() {}",
|
||||
@@ -8471,7 +8442,7 @@ impl ToOffset for MultiBufferOffset {
|
||||
}
|
||||
|
||||
impl ToOffset for MultiBufferOffsetUtf16 {
|
||||
fn to_offset<'a>(&self, snapshot: &MultiBufferSnapshot) -> MultiBufferOffset {
|
||||
fn to_offset(&self, snapshot: &MultiBufferSnapshot) -> MultiBufferOffset {
|
||||
snapshot.offset_utf16_to_offset(*self)
|
||||
}
|
||||
|
||||
@@ -8481,7 +8452,7 @@ impl ToOffset for MultiBufferOffsetUtf16 {
|
||||
}
|
||||
|
||||
impl ToOffset for PointUtf16 {
|
||||
fn to_offset<'a>(&self, snapshot: &MultiBufferSnapshot) -> MultiBufferOffset {
|
||||
fn to_offset(&self, snapshot: &MultiBufferSnapshot) -> MultiBufferOffset {
|
||||
snapshot.point_utf16_to_offset(*self)
|
||||
}
|
||||
fn to_offset_utf16(&self, snapshot: &MultiBufferSnapshot) -> MultiBufferOffsetUtf16 {
|
||||
@@ -8490,28 +8461,28 @@ impl ToOffset for PointUtf16 {
|
||||
}
|
||||
|
||||
impl ToPoint for MultiBufferOffset {
|
||||
fn to_point<'a>(&self, snapshot: &MultiBufferSnapshot) -> Point {
|
||||
fn to_point(&self, snapshot: &MultiBufferSnapshot) -> Point {
|
||||
snapshot.offset_to_point(*self)
|
||||
}
|
||||
fn to_point_utf16<'a>(&self, snapshot: &MultiBufferSnapshot) -> PointUtf16 {
|
||||
fn to_point_utf16(&self, snapshot: &MultiBufferSnapshot) -> PointUtf16 {
|
||||
snapshot.offset_to_point_utf16(*self)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPoint for Point {
|
||||
fn to_point<'a>(&self, _: &MultiBufferSnapshot) -> Point {
|
||||
fn to_point(&self, _: &MultiBufferSnapshot) -> Point {
|
||||
*self
|
||||
}
|
||||
fn to_point_utf16<'a>(&self, snapshot: &MultiBufferSnapshot) -> PointUtf16 {
|
||||
fn to_point_utf16(&self, snapshot: &MultiBufferSnapshot) -> PointUtf16 {
|
||||
snapshot.point_to_point_utf16(*self)
|
||||
}
|
||||
}
|
||||
|
||||
impl ToPoint for PointUtf16 {
|
||||
fn to_point<'a>(&self, snapshot: &MultiBufferSnapshot) -> Point {
|
||||
fn to_point(&self, snapshot: &MultiBufferSnapshot) -> Point {
|
||||
snapshot.point_utf16_to_point(*self)
|
||||
}
|
||||
fn to_point_utf16<'a>(&self, _: &MultiBufferSnapshot) -> PointUtf16 {
|
||||
fn to_point_utf16(&self, _: &MultiBufferSnapshot) -> PointUtf16 {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6363,9 +6363,7 @@ impl ReferenceMultibuffer {
|
||||
let base_buffer = diff.base_text();
|
||||
|
||||
let mut offset = buffer_range.start;
|
||||
let hunks = diff
|
||||
.hunks_intersecting_range(excerpt.range.clone(), buffer)
|
||||
.peekable();
|
||||
let hunks = diff.hunks_intersecting_range(excerpt.range.clone(), buffer);
|
||||
|
||||
for hunk in hunks {
|
||||
// Ignore hunks that are outside the excerpt range.
|
||||
|
||||
@@ -1796,10 +1796,7 @@ impl OutlinePanel {
|
||||
.first()
|
||||
.is_some_and(|entry| entry.path.is_empty()),
|
||||
PanelEntry::Fs(FsEntry::ExternalFile(_)) => false,
|
||||
PanelEntry::Outline(_) | PanelEntry::Search(_) => {
|
||||
cx.notify();
|
||||
return;
|
||||
}
|
||||
PanelEntry::Outline(_) | PanelEntry::Search(_) => return,
|
||||
};
|
||||
let auto_fold_dirs = OutlinePanelSettings::get_global(cx).auto_fold_dirs;
|
||||
let is_foldable = auto_fold_dirs && !is_root && self.is_foldable(&entry);
|
||||
@@ -5435,7 +5432,7 @@ impl OutlinePanel {
|
||||
.child(list_contents.size_full().flex_shrink_1())
|
||||
.custom_scrollbars(
|
||||
Scrollbars::for_settings::<OutlinePanelSettingsScrollbarProxy>()
|
||||
.tracked_scroll_handle(&self.scroll_handle.clone())
|
||||
.tracked_scroll_handle(&self.scroll_handle)
|
||||
.with_track_along(
|
||||
ScrollAxes::Horizontal,
|
||||
cx.theme().colors().panel_background,
|
||||
|
||||
Reference in new issue
Block a user