Skip to content

Commit 0a79639

Browse files
committed
fix: record tokensNumber when type element and backspace
1 parent 81ac2a5 commit 0a79639

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/utils/getActions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const getActions = (node: React.ReactNode, splitter: Splitter) => {
4444
if (child.type === Backspace) {
4545
const count = child.props.count as number;
4646
const payload = count > tokensNumber ? tokensNumber : count;
47+
tokensNumber -= payload;
4748
actions.push(backspace(payload));
4849

4950
return;
@@ -63,6 +64,7 @@ const getActions = (node: React.ReactNode, splitter: Splitter) => {
6364

6465
// if children is undefined or null, treat the child as a single token
6566
if (isNil(child.props.children)) {
67+
tokensNumber += 1;
6668
actions.push(typeToken(child));
6769
return;
6870
}

0 commit comments

Comments
 (0)