markdown preview: Detect language of buffer correctly (#15961)
Fixes #15958 Release Notes: - Fixed an issue where the markdown preview button would not show up for some markdown files ([#15958](https://github.com/zed-industries/zed/issues/15958)).
This commit is contained in:
parent
da8d1306af
commit
e69b0833aa
1 changed files with 7 additions and 4 deletions
|
@ -279,10 +279,13 @@ impl MarkdownPreviewView {
|
|||
}
|
||||
|
||||
pub fn is_markdown_file<V>(editor: &View<Editor>, cx: &mut ViewContext<V>) -> bool {
|
||||
let language = editor.read(cx).buffer().read(cx).language_at(0, cx);
|
||||
language
|
||||
.map(|l| l.name().as_ref() == "Markdown")
|
||||
.unwrap_or(false)
|
||||
let buffer = editor.read(cx).buffer().read(cx);
|
||||
if let Some(buffer) = buffer.as_singleton() {
|
||||
if let Some(language) = buffer.read(cx).language() {
|
||||
return language.name().as_ref() == "Markdown";
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
fn set_editor(&mut self, editor: View<Editor>, cx: &mut ViewContext<Self>) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue