fix outline, multiple symbols defined on the same line:

eg:
int i, j, k;

outline before:
k
 j
  i
after:
i
j
k
This commit is contained in:
Ludovic Jozeau 2021-04-04 10:29:52 +02:00
parent 407f78e658
commit 48b51507fd
No known key found for this signature in database
GPG Key ID: 881AEC6AAD9BEA6C

View File

@ -158,10 +158,13 @@ void MessageHandler::textDocument_documentSymbol(JsonReader &reader,
/**
* with 2 ranges that start at the same Position, we want the wider one
* first (swap lhs/rhs)
*
* we use range for start to start at symbol name
* issue with: int i, j, k; otherwise
*/
auto sym_cmp = [](ExtentRef const &lhs, ExtentRef const &rhs) {
return lhs.extent.start < rhs.extent.start ||
(lhs.extent.start == rhs.extent.start &&
return lhs.range.start < rhs.range.start ||
(lhs.range.start == rhs.range.start &&
rhs.extent.end < lhs.extent.end);
};
@ -197,7 +200,10 @@ void MessageHandler::textDocument_documentSymbol(JsonReader &reader,
if (!ignore(def) && (ds.kind == SymbolKind::Namespace || allows(sym))) {
// drop symbols that are behind the current one
while (!indent.empty() && indent.top()->range.end < ds.range.start) {
while (!indent.empty() &&
// use selectionRange for start to start at symbol name
// issue with: int i, j, k; otherwise
indent.top()->range.end < ds.selectionRange.start) {
indent.pop();
}
if (indent.empty()) {