Fix empty trees line counting (#539)

Refs #450
This commit is contained in:
Mikhail f. Shiryaev
2021-05-11 14:50:05 +02:00
committed by GitHub
parent 2a1df71375
commit c893dbf25c
3 changed files with 53 additions and 1 deletions
+3 -1
View File
@@ -226,7 +226,9 @@ func tomlValueStringRepresentation(v interface{}, commented string, indent strin
}
func getTreeArrayLine(trees []*Tree) (line int) {
// get lowest line number that is not 0
// Prevent returning 0 for empty trees
line = int(^uint(0) >> 1)
// get lowest line number >= 0
for _, tv := range trees {
if tv.position.Line < line || line == 0 {
line = tv.position.Line