diff --git a/crates/editor/src/multi_buffer.rs b/crates/editor/src/multi_buffer.rs index 264bd3f562..6047c1caf5 100644 --- a/crates/editor/src/multi_buffer.rs +++ b/crates/editor/src/multi_buffer.rs @@ -452,12 +452,14 @@ impl MultiBuffer { } pub fn language<'a>(&self, cx: &'a AppContext) -> Option<&'a Arc> { - self.as_singleton().unwrap().read(cx).language() + self.buffers + .values() + .next() + .and_then(|state| state.buffer.read(cx).language()) } pub fn file<'a>(&self, cx: &'a AppContext) -> Option<&'a dyn File> { - self.as_singleton() - .and_then(|buffer| buffer.read(cx).file()) + self.as_singleton().unwrap().read(cx).file() } pub fn is_dirty(&self, cx: &AppContext) -> bool { @@ -1057,7 +1059,10 @@ impl MultiBufferSnapshot { } pub fn language(&self) -> Option<&Arc> { - self.as_singleton().unwrap().language() + self.excerpts + .iter() + .next() + .and_then(|excerpt| excerpt.buffer.language()) } pub fn diagnostic_group<'a, O>(