mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-26 09:31:59 +00:00
Fix shrinking region. (#290)
This commit is contained in:
parent
a7215c233c
commit
16f6fdbef1
@ -142,15 +142,15 @@ void EmitSemanticHighlighting(QueryDatabase* db,
|
||||
// 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 =
|
||||
const 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
|
||||
int col = sym.loc.range.start.column - 1;
|
||||
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;
|
||||
}
|
||||
|
@ -40,13 +40,13 @@ WorkingFile::WorkingFile(const std::string& filename,
|
||||
}
|
||||
|
||||
void WorkingFile::SetIndexContent(const std::string& index_content) {
|
||||
index_lines = ToLines(index_content, true /*trim_whitespace*/);
|
||||
index_lines = ToLines(index_content, false /*trim_whitespace*/);
|
||||
|
||||
// Build lookup buffer.
|
||||
index_lines_lookup.clear();
|
||||
index_lines_lookup.reserve(index_lines.size());
|
||||
for (int i = 0; i < index_lines.size(); ++i) {
|
||||
const std::string& index_line = index_lines[i];
|
||||
std::string index_line = Trim(index_lines[i]);
|
||||
|
||||
auto it = index_lines_lookup.find(index_line);
|
||||
if (it == index_lines_lookup.end())
|
||||
@ -97,7 +97,7 @@ optional<int> WorkingFile::GetBufferLineFromIndexLine(int index_line) const {
|
||||
|
||||
// Find the line in the cached index file. We'll try to find the most similar
|
||||
// line in the buffer and return the index for that.
|
||||
std::string index = index_lines[index_line - 1];
|
||||
std::string index = Trim(index_lines[index_line - 1]);
|
||||
auto buffer_it = all_buffer_lines_lookup.find(index);
|
||||
if (buffer_it == all_buffer_lines_lookup.end()) {
|
||||
// TODO: Use levenshtein distance to find the best match (but only to an
|
||||
|
Loading…
Reference in New Issue
Block a user