Skip to content

Commit 8c07814

Browse files
bors[bot]vsrs
andauthored
Merge #10662
10662: Fix Plaintext textDocument/hover r=Veykril a=vsrs Relates to #10028 Note: the PR corrects only invalid content kind, not formatting. Co-authored-by: vsrs <[email protected]>
2 parents b9fa37f + 2f862cd commit 8c07814

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

crates/rust-analyzer/src/cli/lsif.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ impl LsifManager<'_> {
136136
result: lsp_types::Hover {
137137
contents: lsp_types::HoverContents::Markup(to_proto::markup_content(
138138
hover.markup,
139+
ide::HoverDocFormat::Markdown,
139140
)),
140141
range: None,
141142
},

crates/rust-analyzer/src/handlers.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,9 +920,14 @@ pub(crate) fn handle_hover(
920920

921921
let line_index = snap.file_line_index(file_range.file_id)?;
922922
let range = to_proto::range(&line_index, info.range);
923+
let markup_kind =
924+
snap.config.hover().documentation.map_or(ide::HoverDocFormat::Markdown, |kind| kind);
923925
let hover = lsp_ext::Hover {
924926
hover: lsp_types::Hover {
925-
contents: HoverContents::Markup(to_proto::markup_content(info.info.markup)),
927+
contents: HoverContents::Markup(to_proto::markup_content(
928+
info.info.markup,
929+
markup_kind,
930+
)),
926931
range: Some(range),
927932
},
928933
actions: if snap.config.hover_actions().none() {

crates/rust-analyzer/src/to_proto.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,9 +1202,16 @@ pub(crate) fn reference_title(count: usize) -> String {
12021202
}
12031203
}
12041204

1205-
pub(crate) fn markup_content(markup: Markup) -> lsp_types::MarkupContent {
1205+
pub(crate) fn markup_content(
1206+
markup: Markup,
1207+
kind: ide::HoverDocFormat,
1208+
) -> lsp_types::MarkupContent {
1209+
let kind = match kind {
1210+
ide::HoverDocFormat::Markdown => lsp_types::MarkupKind::Markdown,
1211+
ide::HoverDocFormat::PlainText => lsp_types::MarkupKind::PlainText,
1212+
};
12061213
let value = crate::markdown::format_docs(markup.as_str());
1207-
lsp_types::MarkupContent { kind: lsp_types::MarkupKind::Markdown, value }
1214+
lsp_types::MarkupContent { kind, value }
12081215
}
12091216

12101217
pub(crate) fn rename_error(err: RenameError) -> crate::LspError {

0 commit comments

Comments
 (0)