From 58c701d98a2801bd3a80c4fa145857133119cd2f Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 7 Nov 2018 17:20:41 -0800 Subject: [PATCH] Improve semantic highlight in templates --- src/message_handler.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/message_handler.cc b/src/message_handler.cc index ddb03031..969c691b 100644 --- a/src/message_handler.cc +++ b/src/message_handler.cc @@ -91,15 +91,19 @@ struct ScanLineEvent { Position end_pos; // Second key when there is a tie for insertion events. int id; CclsSemanticHighlightSymbol *symbol; - bool operator<(const ScanLineEvent &other) const { + bool operator<(const ScanLineEvent &o) const { // See the comments below when insertion/deletion events are inserted. - if (!(pos == other.pos)) - return pos < other.pos; - if (!(other.end_pos == end_pos)) - return other.end_pos < end_pos; + if (!(pos == o.pos)) + return pos < o.pos; + if (!(o.end_pos == end_pos)) + return o.end_pos < end_pos; // This comparison essentially order Macro after non-Macro, // So that macros will not be rendered as Var/Type/... - return symbol->kind < other.symbol->kind; + if (symbol->kind != o.symbol->kind) + return symbol->kind < o.symbol->kind; + // If symbol A and B occupy the same place, we want one to be placed + // before the other consistantly. + return symbol->id < o.symbol->id; } }; } // namespace