Hack to restrict the region.

This commit is contained in:
Chao Shen 2018-01-09 14:48:42 +08:00 committed by Fangrui Song
parent 5d94d138cf
commit 6a03a86e64

View File

@ -136,6 +136,22 @@ void EmitSemanticHighlighting(QueryDatabase* db,
continue; // applies to for loop continue; // applies to for loop
is_type_member = func->def->declaring_type.has_value(); is_type_member = func->def->declaring_type.has_value();
detailed_name = func->def->short_name; detailed_name = func->def->short_name;
// TODO We use cursor extent for lambda definition. Without the region
// shrinking hack, the contained keywords and primitive types will be
// highlighted undesiredly.
auto concise_name = detailed_name.substr(0, detailed_name.find('<'));
if (sym.loc.range.start.line <= working_file->index_lines.size()) {
std::string& line =
working_file->index_lines[sym.loc.range.start.line - 1];
auto pos = line.find(concise_name);
sym.loc.range.end.line = sym.loc.range.start.line;
if (pos == std::string::npos)
sym.loc.range.end.column = sym.loc.range.start.column;
else
sym.loc.range.end.column =
sym.loc.range.start.column + concise_name.size();
}
break; break;
} }
case SymbolKind::Var: { case SymbolKind::Var: {