From 8b450a7d58f92d440d1a68555738727908ecc089 Mon Sep 17 00:00:00 2001 From: Kristin Laemmert Date: Tue, 2 Apr 2019 16:08:43 -0400 Subject: [PATCH] hclsyntax: return the starting position of a missing attr, not the end. (#97) Previously, hclsyntax MissingItemRange() function returned a zero-length range anchored at the end of the block in question. This commit changes that to the beginning of the block. In practice, the end of a block is generally just a "}" and not very useful in error messages. --- hcl/hclsyntax/structure.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hcl/hclsyntax/structure.go b/hcl/hclsyntax/structure.go index 22e389c..476025d 100644 --- a/hcl/hclsyntax/structure.go +++ b/hcl/hclsyntax/structure.go @@ -279,7 +279,11 @@ func (b *Body) JustAttributes() (hcl.Attributes, hcl.Diagnostics) { } func (b *Body) MissingItemRange() hcl.Range { - return b.EndRange + return hcl.Range{ + Filename: b.SrcRange.Filename, + Start: b.SrcRange.Start, + End: b.SrcRange.Start, + } } // Attributes is the collection of attribute definitions within a body.