diff --git a/src/messages/textDocument_rename.cc b/src/messages/textDocument_rename.cc index 7c478b128..1ec643b1a 100644 --- a/src/messages/textDocument_rename.cc +++ b/src/messages/textDocument_rename.cc @@ -21,12 +21,18 @@ namespace { WorkspaceEdit BuildWorkspaceEdit(DB *db, WorkingFiles *wfiles, SymbolRef sym, const std::string &new_text) { std::unordered_map path_to_edit; + Location last_location; // prevent duplicates EachOccurrence(db, sym, true, [&](Use use) { std::optional 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();