Browse Source

ctags: location.symbol and location.source should now correspond with respect to escaping

pipelines/1486128344
eidheim 2 years ago
parent
commit
fe16979289
  1. 16
      src/ctags.cpp

16
src/ctags.cpp

@ -102,7 +102,21 @@ Ctags::Location Ctags::get_location(const std::string &line_, bool add_markup, b
auto symbol_end = line.find('\t');
if(symbol_end == std::string::npos)
return location;
location.symbol = line.substr(0, symbol_end);
// Unescape symbol
if(symbol_end > 0) {
location.symbol.reserve(symbol_end);
bool escaped = false;
for(size_t i = 0; i < symbol_end; ++i) {
if(!escaped && line[i] == '\\') {
escaped = true;
continue;
}
escaped = false;
location.symbol += line[i];
}
}
if(9 < location.symbol.size() && location.symbol[8] == ' ' && starts_with(location.symbol, "operator")) {
auto &chr = location.symbol[9];
if(!((chr >= 'A' && chr <= 'Z') || (chr >= 'a' && chr <= 'z') || (chr >= '0' && chr <= '9') || chr == '_' || chr == '$' || static_cast<unsigned char>(chr) >= 128))

Loading…
Cancel
Save