Mutate the doc.parts array when printing fill (#3273)
parent
66d9b266e8
commit
8e5c335bda
|
@ -297,10 +297,16 @@ function printDocToString(doc, options) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const remaining = parts.slice(2);
|
// At this point we've handled the first pair (context, separator)
|
||||||
const remainingCmd = [ind, mode, fill(remaining)];
|
// and will create a new fill doc for the rest of the content.
|
||||||
|
// Ideally we wouldn't mutate the array here but coping all the
|
||||||
|
// elements to a new array would make this algorithm quadratic,
|
||||||
|
// which is unusable for large arrays (e.g. large texts in JSX).
|
||||||
|
parts.splice(0, 2);
|
||||||
|
const remainingCmd = [ind, mode, fill(parts)];
|
||||||
|
|
||||||
|
const secondContent = parts[0];
|
||||||
|
|
||||||
const secondContent = parts[2];
|
|
||||||
const firstAndSecondContentFlatCmd = [
|
const firstAndSecondContentFlatCmd = [
|
||||||
ind,
|
ind,
|
||||||
MODE_FLAT,
|
MODE_FLAT,
|
||||||
|
|
Loading…
Reference in New Issue