Merge pull request #2417 from zed-industries/hover-markdown

Render markdown more correctly in the editor hover popover
This commit is contained in:
Max Brunsfeld 2023-04-27 14:15:04 -07:00 committed by GitHub
commit 7258db7a4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 827 additions and 307 deletions

View file

@ -36,7 +36,7 @@ use language::{
};
use lsp::{
DiagnosticSeverity, DiagnosticTag, DidChangeWatchedFilesRegistrationOptions,
DocumentHighlightKind, LanguageServer, LanguageServerId, LanguageString, MarkedString,
DocumentHighlightKind, LanguageServer, LanguageServerId,
};
use lsp_command::*;
use lsp_glob_set::LspGlobSet;
@ -287,27 +287,14 @@ pub struct Symbol {
#[derive(Clone, Debug, PartialEq)]
pub struct HoverBlock {
pub text: String,
pub language: Option<String>,
pub kind: HoverBlockKind,
}
impl HoverBlock {
fn try_new(marked_string: MarkedString) -> Option<Self> {
let result = match marked_string {
MarkedString::LanguageString(LanguageString { language, value }) => HoverBlock {
text: value,
language: Some(language),
},
MarkedString::String(text) => HoverBlock {
text,
language: None,
},
};
if result.text.is_empty() {
None
} else {
Some(result)
}
}
#[derive(Clone, Debug, PartialEq)]
pub enum HoverBlockKind {
PlainText,
Markdown,
Code { language: String },
}
#[derive(Debug)]