Assume all excerpts in the multi buffer have the same language for now

This commit is contained in:
Antonio Scandurra 2021-12-14 11:33:53 +01:00
parent 04ffca95c6
commit 174b37cdf0

View file

@ -452,12 +452,14 @@ impl MultiBuffer {
} }
pub fn language<'a>(&self, cx: &'a AppContext) -> Option<&'a Arc<Language>> { pub fn language<'a>(&self, cx: &'a AppContext) -> Option<&'a Arc<Language>> {
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> { pub fn file<'a>(&self, cx: &'a AppContext) -> Option<&'a dyn File> {
self.as_singleton() self.as_singleton().unwrap().read(cx).file()
.and_then(|buffer| buffer.read(cx).file())
} }
pub fn is_dirty(&self, cx: &AppContext) -> bool { pub fn is_dirty(&self, cx: &AppContext) -> bool {
@ -1057,7 +1059,10 @@ impl MultiBufferSnapshot {
} }
pub fn language(&self) -> Option<&Arc<Language>> { pub fn language(&self) -> Option<&Arc<Language>> {
self.as_singleton().unwrap().language() self.excerpts
.iter()
.next()
.and_then(|excerpt| excerpt.buffer.language())
} }
pub fn diagnostic_group<'a, O>( pub fn diagnostic_group<'a, O>(