This commit is contained in:
Liang Ding 2023-01-27 19:21:56 +08:00
parent 2b09ea75f0
commit 6235d722d1
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -87,7 +87,7 @@ func toFlatTree(blocks []*Block, baseDepth int, typ string) (ret []*Path) {
for _, block := range blocks { for _, block := range blocks {
root := getBlockIn(blockRoots, block.RootID) root := getBlockIn(blockRoots, block.RootID)
if nil == root { if nil == root {
root, _ = getBlock(block.RootID) root, _ = getBlock(block.RootID, nil)
blockRoots = append(blockRoots, root) blockRoots = append(blockRoots, root)
} }
if nil == root { if nil == root {
@ -134,7 +134,7 @@ func toSubTree(blocks []*Block, keyword string) (ret []*Path) {
for _, block := range blocks { for _, block := range blocks {
root := getBlockIn(blockRoots, block.RootID) root := getBlockIn(blockRoots, block.RootID)
if nil == root { if nil == root {
root, _ = getBlock(block.RootID) root, _ = getBlock(block.RootID, nil)
blockRoots = append(blockRoots, root) blockRoots = append(blockRoots, root)
} }
block.Depth = 1 block.Depth = 1
@ -195,11 +195,11 @@ func toSubTree(blocks []*Block, keyword string) (ret []*Path) {
} }
} }
for next := li.FirstChild.Next; nil != next; next = next.Next { for next := li.FirstChild.Next; nil != next; next = next.Next {
subBlock, _ := getBlock(next.ID) subBlock, _ := getBlock(next.ID, tree)
if unfold { if unfold {
if ast.NodeList == next.Type { if ast.NodeList == next.Type {
for subLi := next.FirstChild; nil != subLi; subLi = subLi.Next { for subLi := next.FirstChild; nil != subLi; subLi = subLi.Next {
subLiBlock, _ := getBlock(subLi.ID) subLiBlock, _ := getBlock(subLi.ID, tree)
var subFirst *sql.Block var subFirst *sql.Block
if 3 != subLi.ListData.Typ { if 3 != subLi.ListData.Typ {
subFirst = sql.GetBlock(subLi.FirstChild.ID) subFirst = sql.GetBlock(subLi.FirstChild.ID)
@ -224,7 +224,7 @@ func toSubTree(blocks []*Block, keyword string) (ret []*Path) {
headingChildren := treenode.HeadingChildren(next) headingChildren := treenode.HeadingChildren(next)
var breakSub bool var breakSub bool
for _, n := range headingChildren { for _, n := range headingChildren {
block, _ := getBlock(n.ID) block, _ := getBlock(n.ID, tree)
subPos := 0 subPos := 0
content := block.Content content := block.Content
if "" != keyword { if "" != keyword {
@ -295,7 +295,7 @@ func toSubTree(blocks []*Block, keyword string) (ret []*Path) {
for _, headingChild := range headingChildren { for _, headingChild := range headingChildren {
if ast.NodeList == headingChild.Type { if ast.NodeList == headingChild.Type {
for subLi := headingChild.FirstChild; nil != subLi; subLi = subLi.Next { for subLi := headingChild.FirstChild; nil != subLi; subLi = subLi.Next {
subLiBlock, _ := getBlock(subLi.ID) subLiBlock, _ := getBlock(subLi.ID, tree)
var subFirst *sql.Block var subFirst *sql.Block
if 3 != subLi.ListData.Typ { if 3 != subLi.ListData.Typ {
subFirst = sql.GetBlock(subLi.FirstChild.ID) subFirst = sql.GetBlock(subLi.FirstChild.ID)
@ -315,7 +315,7 @@ func toSubTree(blocks []*Block, keyword string) (ret []*Path) {
subRoot.Blocks = append(subRoot.Blocks, subLiBlock) subRoot.Blocks = append(subRoot.Blocks, subLiBlock)
} }
} else { } else {
subBlock, _ := getBlock(headingChild.ID) subBlock, _ := getBlock(headingChild.ID, tree)
subBlock.Depth = 2 subBlock.Depth = 2
subRoot.Blocks = append(subRoot.Blocks, subBlock) subRoot.Blocks = append(subRoot.Blocks, subBlock)
} }