Skip to content

Commit

Permalink
only coalesce if subbed
Browse files Browse the repository at this point in the history
  • Loading branch information
alixander committed Jul 11, 2023
1 parent 22bd50a commit 78e9e45
Show file tree
Hide file tree
Showing 180 changed files with 869 additions and 459 deletions.
11 changes: 9 additions & 2 deletions d2ir/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,27 +108,34 @@ func (c *compiler) resolveSubstitutions(refctx *RefContext) {
varsMap = vars.Map()
}

subbed := false
switch {
case refctx.Key.Value.UnquotedString != nil:
for i, box := range refctx.Key.Value.UnquotedString.Value {
if box.Substitution != nil {
resolvedField := c.resolveSubstitution(varsMap, refctx.Key, box.Substitution)
if resolvedField != nil {
refctx.Key.Value.UnquotedString.Value[i].String = go2.Pointer(resolvedField.Primary().String())
subbed = true
}
}
}
refctx.Key.Value.UnquotedString.Coalesce()
if subbed {
refctx.Key.Value.UnquotedString.Coalesce()
}
case refctx.Key.Value.DoubleQuotedString != nil:
for i, box := range refctx.Key.Value.DoubleQuotedString.Value {
if box.Substitution != nil {
resolvedField := c.resolveSubstitution(varsMap, refctx.Key, box.Substitution)
if resolvedField != nil {
refctx.Key.Value.DoubleQuotedString.Value[i].String = go2.Pointer(resolvedField.Primary().String())
subbed = true
}
}
}
refctx.Key.Value.DoubleQuotedString.Coalesce()
if subbed {
refctx.Key.Value.DoubleQuotedString.Coalesce()
}
}
}

Expand Down
Binary file modified e2etests-cli/testdata/TestCLI_E2E/internal_linked_pdf.exp.pdf
Binary file not shown.
15 changes: 7 additions & 8 deletions testdata/d2compiler/TestCompile/array-classes.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion testdata/d2compiler/TestCompile/basic_icon.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion testdata/d2compiler/TestCompile/basic_sequence.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion testdata/d2compiler/TestCompile/basic_shape.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions testdata/d2compiler/TestCompile/class-shape-class.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions testdata/d2compiler/TestCompile/class_paren.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions testdata/d2compiler/TestCompile/class_style.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 19 additions & 14 deletions testdata/d2compiler/TestCompile/classes.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 16 additions & 8 deletions testdata/d2compiler/TestCompile/dimensions_on_containers.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 78e9e45

Please sign in to comment.