Skip to content

Commit 6403a45

Browse files
committed
[delta] slice may start somewhere else
1 parent 85f4df5 commit 6403a45

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

delta/delta.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ export const $attribution = /*@__PURE__*/(()=>s.$object({
4646
formatAt: s.$number.optional
4747
}))()
4848

49-
/**
50-
* @typedef {s.Unwrap<$anyOp>} DeltaOps
51-
*/
52-
5349
/**
5450
* @typedef {{ [key: string]: any }} FormattingAttributes
5551
*/
@@ -1146,9 +1142,10 @@ export class Delta extends DeltaData {
11461142
* @param {Delta<DConf>} d
11471143
* @param {number} start
11481144
* @param {number} end
1145+
* @param {ChildrenOpAny?} currNode - start slicing at this node (instead of d.children.start)
11491146
* @return {DeltaBuilder<DConf>}
11501147
*/
1151-
export const slice = (d, start = 0, end = d.childCnt) => {
1148+
export const slice = (d, start = 0, end = d.childCnt, currNode = d.children.start) => {
11521149
const cpy = /** @type {DeltaAny} */ (new DeltaBuilder(d.name, d.$schema))
11531150
cpy.origin = d.origin
11541151
// copy attrs
@@ -1159,10 +1156,6 @@ export const slice = (d, start = 0, end = d.childCnt) => {
11591156
// copy children
11601157
const slicedLen = end - start
11611158
let remainingLen = slicedLen
1162-
/**
1163-
* @type {ChildrenOpAny?}
1164-
*/
1165-
let currNode = /** @type {any} */ (d.children.start)
11661159
let currNodeOffset = 0
11671160
while (start > 0 && currNode != null) {
11681161
if (currNode.length <= start) {

0 commit comments

Comments
 (0)