chore: fix find sibling node

This commit is contained in:
Steven 2024-01-05 08:43:30 +08:00
parent 454cd4e24f
commit ce2d37b90c

View file

@ -5,7 +5,7 @@ func FindPrevSiblingExceptLineBreak(node Node) Node {
return nil
}
prev := node.PrevSibling()
if prev != nil && prev.Type() == LineBreakNode {
if prev != nil && prev.Type() == LineBreakNode && prev.PrevSibling() != nil && prev.PrevSibling().Type() != LineBreakNode {
return FindPrevSiblingExceptLineBreak(prev)
}
return prev
@ -16,7 +16,7 @@ func FindNextSiblingExceptLineBreak(node Node) Node {
return nil
}
next := node.NextSibling()
if next != nil && next.Type() == LineBreakNode {
if next != nil && next.Type() == LineBreakNode && next.NextSibling() != nil && next.NextSibling().Type() != LineBreakNode {
return FindNextSiblingExceptLineBreak(next)
}
return next