Skip to content

Commit

Permalink
fix duplicates in rename ranges MaskRay#294
Browse files Browse the repository at this point in the history
  • Loading branch information
Yan Pashkovsky committed Mar 1, 2019
1 parent a74884e commit 3374445
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/messages/textDocument_rename.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 3374445

Please sign in to comment.