From 8b86781ad13d3e5eee604fb93c15cf943bee8bf5 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 5 Oct 2022 14:44:34 -0700 Subject: [PATCH] Remove last usages of MultiBufferSnapshot::language --- crates/editor/src/editor.rs | 6 ++++-- crates/editor/src/multi_buffer.rs | 7 ------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index f7c9f81c0c..4e18d04889 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -2021,7 +2021,7 @@ impl Editor { let end = selection.end; let mut insert_extra_newline = false; - if let Some(language) = buffer.language() { + if let Some(language) = buffer.language_at(start) { let leading_whitespace_len = buffer .reversed_chars_at(start) .take_while(|c| c.is_whitespace() && *c != '\n') @@ -2927,7 +2927,9 @@ impl Editor { { let indent_size = buffer.indent_size_for_line(line_buffer_range.start.row); - let language_name = buffer.language().map(|language| language.name()); + let language_name = buffer + .language_at(line_buffer_range.start) + .map(|language| language.name()); let indent_len = match indent_size.kind { IndentKind::Space => { cx.global::().tab_size(language_name.as_deref()) diff --git a/crates/editor/src/multi_buffer.rs b/crates/editor/src/multi_buffer.rs index 3b43f99ca0..cf9f29d73e 100644 --- a/crates/editor/src/multi_buffer.rs +++ b/crates/editor/src/multi_buffer.rs @@ -2501,13 +2501,6 @@ impl MultiBufferSnapshot { self.trailing_excerpt_update_count } - pub fn language(&self) -> Option<&Arc> { - self.excerpts - .iter() - .next() - .and_then(|excerpt| excerpt.buffer.language()) - } - pub fn language_at<'a, T: ToOffset>(&'a self, point: T) -> Option<&'a Arc> { self.point_to_buffer_offset(point) .and_then(|(buffer, offset)| buffer.language_at(offset))