Skip to content

Commit

Permalink
[fix] DFS depths when starting from inline node (#7179)
Browse files Browse the repository at this point in the history
  • Loading branch information
fantactuka authored Feb 14, 2025
1 parent b3c64f1 commit ad2511c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ describe('LexicalNodeHelpers tests', () => {

const paragraph = root.getFirstChildOrThrow<ElementNode>();
const children = paragraph.getChildren();
expect($dfs(children[1]).map((step) => step.node)).toEqual([
children[1],
children[2],
expect($dfs(children[1])).toEqual([
{depth: 2, node: children[1]},
{depth: 2, node: children[2]},
]);
},
{discrete: true},
Expand Down
2 changes: 1 addition & 1 deletion packages/lexical-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ function $dfsCaretIterator<D extends CaretDirection>(
const startCaret = $isElementNode(start)
? $getChildCaret(start, direction)
: $getSiblingCaret(start, direction);
const startDepth = $getDepth(startCaret.getParentAtCaret());
const startDepth = $getDepth(start);
const endCaret = $getAdjacentChildCaret(
endNode
? $getChildCaretOrSelf($getSiblingCaret(endNode, direction))
Expand Down

0 comments on commit ad2511c

Please sign in to comment.