mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-15 21:07:20 +01:00
fix(pregate): literals reports every removed value when the name still has one, so a delete-plus-edit keeps the edited site's old value (GST-1211 review)
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
fe05b3ccf5
commit
568cb9dca6
3 files changed
+6
-2
No files matched your search
@@ -73,8 +73,9 @@ export function changedLiterals(file: string, oldText: string, newText: string):
|
||||
if (oldC.has(name)) continue;
|
||||
const added = [...(newCall.get(name) ?? [])];
|
||||
const removed = olds.filter(v => { const i = added.indexOf(v); if (i >= 0) added.splice(i, 1); return i < 0; });
|
||||
if (!added.length) continue;
|
||||
const seen = new Set<string>();
|
||||
removed.forEach((old, i) => { if (i < added.length && !seen.has(old)) { seen.add(old); out.push({ name, old, new: added[i]!, file }); } });
|
||||
removed.forEach((old, i) => { if (!seen.has(old)) { seen.add(old); out.push({ name, old, new: added[Math.min(i, added.length - 1)]!, file }); } });
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user