Unified · Split
| @@ -60,10 +60,10 @@ use itertools::Itertools; · 59 unmodified lines | |||
| 60 | pub use language::{char_kind, CharKind}; | 60 | pub use language::{char_kind, CharKind}; |
| 61 | use language::{ | 61 | use language::{ |
| 62 | language_settings::{self, all_language_settings, InlayHintSettings}, | 62 | language_settings::{self, all_language_settings, InlayHintSettings}, |
| 63 | point_from_lsp, AutoindentMode, BracketPair, Buffer, CodeAction, CodeLabel, Completion, | 63 | point_from_lsp, prepare_completion_documentation, AutoindentMode, BracketPair, Buffer, |
| 64 | CursorShape, Diagnostic, DiagnosticSeverity, File, IndentKind, IndentSize, Language, | 64 | CodeAction, CodeLabel, Completion, CursorShape, Diagnostic, DiagnosticSeverity, Documentation, |
| 65 | LanguageServerName, OffsetRangeExt, OffsetUtf16, Point, Selection, SelectionGoal, | 65 | File, IndentKind, IndentSize, Language, LanguageServerName, OffsetRangeExt, OffsetUtf16, Point, |
| 66 | TransactionId, | 66 | Selection, SelectionGoal, TransactionId, |
| 67 | }; | 67 | }; |
| 68 | use link_go_to_definition::{ | 68 | use link_go_to_definition::{ |
| 69 | hide_link_definition, show_link_definition, GoToDefinitionLink, InlayHighlight, | 69 | hide_link_definition, show_link_definition, GoToDefinitionLink, InlayHighlight, |
| @@ -1075,21 +1075,37 @@ impl CompletionsMenu { · 1005 unmodified lines | |||
| 1075 | }) | 1075 | }) |
| 1076 | .map(|(ix, _)| ix); | 1076 | .map(|(ix, _)| ix); |
| 1077 | 1077 | ||
| 1078 | let project = editor.project.clone(); | ||
| 1078 | let completions = self.completions.clone(); | 1079 | let completions = self.completions.clone(); |
| 1079 | let matches = self.matches.clone(); | 1080 | let matches = self.matches.clone(); |
| 1080 | let selected_item = self.selected_item; | 1081 | let selected_item = self.selected_item; |
| 1081 | 1082 | ||
| 1082 | let alongside_docs_width = style.autocomplete.alongside_docs_width; | ||
| 1083 | let alongside_docs_container_style = style.autocomplete.alongside_docs_container; | ||
| 1084 | let outer_container_style = style.autocomplete.container; | ||
| 1085 | |||
| 1086 | let list = UniformList::new(self.list.clone(), matches.len(), cx, { | 1083 | let list = UniformList::new(self.list.clone(), matches.len(), cx, { |
| 1087 | let style = style.clone(); | 1084 | let style = style.clone(); |
| 1088 | move |_, range, items, cx| { | 1085 | move |_, range, items, cx| { |
| 1089 | let start_ix = range.start; | 1086 | let start_ix = range.start; |
| 1090 | let completions = completions.read(); | 1087 | let mut completions = completions.write(); |
| 1088 | |||
| 1091 | for (ix, mat) in matches[range].iter().enumerate() { | 1089 | for (ix, mat) in matches[range].iter().enumerate() { |
| 1092 | let completion = &completions[mat.candidate_id]; | 1090 | let completion = &mut completions[mat.candidate_id]; |
| 1091 | |||
| 1092 | if completion.documentation.is_none() { | ||
| 1093 | if let Some(lsp_docs) = &completion.lsp_completion.documentation { | ||
| 1094 | let project = project | ||
| 1095 | .as_ref() | ||
| 1096 | .expect("It is impossible have LSP servers without a project"); | ||
| 1097 | |||
| 1098 | let language_registry = project.read(cx).languages(); | ||
| 1099 | |||
| 1100 | completion.documentation = prepare_completion_documentation( | ||
| 1101 | lsp_docs, | ||
| 1102 | language_registry, | ||
| 1103 | None, | ||
| 1104 | &style.theme, | ||
| 1105 | ); | ||
| 1106 | } | ||
| 1107 | } | ||
| 1108 | |||
| 1093 | let documentation = &completion.documentation; | 1109 | let documentation = &completion.documentation; |
| 1094 | let item_ix = start_ix + ix; | 1110 | let item_ix = start_ix + ix; |
| 1095 | 1111 | ||
| @@ -1121,9 +1137,7 @@ impl CompletionsMenu { · 25 unmodified lines | |||
| 1121 | ), | 1137 | ), |
| 1122 | ); | 1138 | ); |
| 1123 | 1139 | ||
| 1124 | if let Some(language::Documentation::SingleLine(text)) = | 1140 | if let Some(Documentation::SingleLine(text)) = documentation { |
| 1125 | documentation | ||
| 1126 | { | ||
| 1127 | Flex::row() | 1141 | Flex::row() |
| 1128 | .with_child(completion_label) | 1142 | .with_child(completion_label) |
| 1129 | .with_children((|| { | 1143 | .with_children((|| { |
| @@ -1209,11 +1223,11 @@ impl CompletionsMenu { · 79 unmodified lines | |||
| 1209 | let documentation = &completion.documentation; | 1223 | let documentation = &completion.documentation; |
| 1210 | 1224 | ||
| 1211 | match documentation { | 1225 | match documentation { |
| 1212 | Some(language::Documentation::MultiLinePlainText(text)) => { | 1226 | Some(Documentation::MultiLinePlainText(text)) => { |
| 1213 | Some(Text::new(text.clone(), style.text.clone())) | 1227 | Some(Text::new(text.clone(), style.text.clone())) |
| 1214 | } | 1228 | } |
| 1215 | 1229 | ||
| 1216 | Some(language::Documentation::MultiLineMarkdown(parsed)) => { | 1230 | Some(Documentation::MultiLineMarkdown(parsed)) => { |
| 1217 | Some(render_parsed_markdown(parsed, &style, cx)) | 1231 | Some(render_parsed_markdown(parsed, &style, cx)) |
| 1218 | } | 1232 | } |
| 1219 | 1233 | ||
| @@ -1221,7 +1235,7 @@ impl CompletionsMenu { · 1 unmodified line | |||
| 1221 | } | 1235 | } |
| 1222 | }) | 1236 | }) |
| 1223 | .contained() | 1237 | .contained() |
| 1224 | .with_style(outer_container_style) | 1238 | .with_style(style.autocomplete.container) |
| 1225 | .into_any() | 1239 | .into_any() |
| 1226 | } | 1240 | } |
| 1227 | 1241 | ||