Skip to content

Commit

Permalink
Merge pull request #2180 from alixander/nested-layer-ref
Browse files Browse the repository at this point in the history
d2lsp: fix nested board finding
  • Loading branch information
alixander authored Oct 30, 2024
2 parents c775a9b + 9e60c10 commit b2cf9d3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
6 changes: 3 additions & 3 deletions d2ir/d2ir.go
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,7 @@ func (m *Map) FindBoardRoot(path []string) *Map {
if len(path) == 1 {
return f.Map()
}
return layersf.Map().FindBoardRoot(path[1:])
return f.Map().FindBoardRoot(path[1:])
}
}
}
Expand All @@ -1849,7 +1849,7 @@ func (m *Map) FindBoardRoot(path []string) *Map {
if len(path) == 1 {
return f.Map()
}
return scenariosf.Map().FindBoardRoot(path[1:])
return f.Map().FindBoardRoot(path[1:])
}
}
}
Expand All @@ -1860,7 +1860,7 @@ func (m *Map) FindBoardRoot(path []string) *Map {
if len(path) == 1 {
return f.Map()
}
return stepsf.Map().FindBoardRoot(path[1:])
return f.Map().FindBoardRoot(path[1:])
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions d2lsp/d2lsp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ hi
layers: {
x: {
hello
layers: {
y: {
qwer
}
}
}
}
`,
Expand All @@ -130,6 +136,10 @@ layers: {
assert.Success(t, err)
assert.Equal(t, 0, len(ranges))

ranges, _, err = d2lsp.GetRefRanges("index.d2", fs, []string{"x", "y"}, "qwer")
assert.Success(t, err)
assert.Equal(t, 1, len(ranges))

_, _, err = d2lsp.GetRefRanges("index.d2", fs, []string{"y"}, "hello")
assert.Equal(t, `board "[y]" not found`, err.Error())
}

0 comments on commit b2cf9d3

Please sign in to comment.