mirror of
https://github.com/MaskRay/ccls.git
synced 2025-06-07 16:54:54 +00:00
fix #294, remove duplicate ranges from rename
This commit is contained in:
parent
00158e2150
commit
0df730e1bc
@ -21,12 +21,18 @@ namespace {
|
||||
WorkspaceEdit BuildWorkspaceEdit(DB *db, WorkingFiles *wfiles, SymbolRef sym,
|
||||
const std::string &new_text) {
|
||||
std::unordered_map<int, TextDocumentEdit> path_to_edit;
|
||||
Location last_location; // prevent duplicates
|
||||
|
||||
EachOccurrence(db, sym, true, [&](Use use) {
|
||||
std::optional<Location> ls_location = GetLsLocation(db, wfiles, use);
|
||||
if (!ls_location)
|
||||
return;
|
||||
|
||||
if (*ls_location == last_location)
|
||||
return;
|
||||
|
||||
last_location = *ls_location;
|
||||
|
||||
int file_id = use.file_id;
|
||||
if (path_to_edit.find(file_id) == path_to_edit.end()) {
|
||||
path_to_edit[file_id] = TextDocumentEdit();
|
||||
|
Loading…
Reference in New Issue
Block a user