From 0951004370a4efa1563e7b9e18b3b32c5460c0fb Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 11 Apr 2019 22:26:07 -0700 Subject: [PATCH] Set RetainCommentsFromSystemHeaders to true Note with -fretain-comments-from-system-headers, the .gch of bits/stdc++.h becomes larger by 1%, but that is fine. And improve comment handling in textDocument/hover Fix #373 --- src/messages/textDocument_hover.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/messages/textDocument_hover.cc b/src/messages/textDocument_hover.cc index 60c00fb9..04093101 100644 --- a/src/messages/textDocument_hover.cc +++ b/src/messages/textDocument_hover.cc @@ -48,8 +48,11 @@ GetHover(DB *db, LanguageId lang, SymbolRef sym, int file_id) { std::optional ls_comments, hover; WithEntity(db, sym, [&](const auto &entity) { for (auto &d : entity.def) { + if (!comments && d.comments[0]) + comments = d.comments; if (d.spell) { - comments = d.comments[0] ? d.comments : nullptr; + if (d.comments[0]) + comments = d.comments; if (const char *s = d.hover[0] ? d.hover : d.detailed_name[0] ? d.detailed_name : nullptr) { @@ -64,8 +67,6 @@ GetHover(DB *db, LanguageId lang, SymbolRef sym, int file_id) { } if (!hover && entity.def.size()) { auto &d = entity.def[0]; - if (d.comments[0]) - comments = d.comments; hover = {LanguageIdentifier(lang)}; if (d.hover[0]) hover->value = d.hover;