From 09d7da28932b77915be8ded1ce9dc6a40f1e6a14 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 29 Jan 2018 09:28:17 -0800 Subject: [PATCH] Don't emit semantic highlight for operators or lambda (#369) Fixes #368 --- src/message_handler.cc | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/message_handler.cc b/src/message_handler.cc index df23c3a7..17c26ed9 100644 --- a/src/message_handler.cc +++ b/src/message_handler.cc @@ -120,27 +120,14 @@ void EmitSemanticHighlighting(QueryDatabase* db, QueryFunc* func = &db->funcs[sym.idx.idx]; if (!func->def) continue; // applies to for loop - if (func->def->short_name.compare(0, 8, "operator") == 0) + // Don't highlight overloadable operators or implicit lambda -> + // std::function constructor. + if (func->def->short_name.compare(0, 8, "operator") == 0 || + func->def->short_name.compare(0, 27, + "functiondef->kind; 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 (0 <= sym.loc.range.start.line && - sym.loc.range.start.line < working_file->index_lines.size()) { - const std::string& line = - working_file->index_lines[sym.loc.range.start.line]; - sym.loc.range.end.line = sym.loc.range.start.line; - int col = sym.loc.range.start.column; - if (line.compare(col, concise_name.size(), concise_name) == 0) - sym.loc.range.end.column = - sym.loc.range.start.column + concise_name.size(); - else - sym.loc.range.end.column = sym.loc.range.start.column; - } break; } case SymbolKind::Var: {