Changeset: Improve handling of missing attribute in old pool

pull/5268/head
Richard Hansen 2021-10-25 05:19:35 -04:00
parent b62534a6b2
commit 4f4a775d9e
1 changed files with 4 additions and 12 deletions

View File

@ -1563,18 +1563,10 @@ exports.moveOpsToNewPool = (cs, oldPool, newPool) => {
// order of attribs stays the same
return upToDollar.replace(/\*([0-9a-z]+)/g, (_, a) => {
const oldNum = exports.parseNum(a);
let pair = oldPool.getAttrib(oldNum);
/*
* Setting an empty pair. Required for when delete pad contents / attributes
* while another user has the timeslider open.
*
* Fixes https://github.com/ether/etherpad-lite/issues/3932
*/
if (!pair) {
pair = [];
}
const pair = oldPool.getAttrib(oldNum);
// The attribute might not be in the old pool if the user is viewing the current revision in the
// timeslider and text is deleted. See: https://github.com/ether/etherpad-lite/issues/3932
if (!pair) return '';
const newNum = newPool.putAttrib(pair);
return `*${exports.numToString(newNum)}`;
}) + fromDollar;