From cb609a188688653d0dfe64b3e156645114fd02f8 Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Tue, 15 Nov 2022 11:35:31 +1100 Subject: [PATCH] Fixed bad line entry for #1422 --- pkg/yqlib/lib.go | 5 ++++- pkg/yqlib/lib_test.go | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/pkg/yqlib/lib.go b/pkg/yqlib/lib.go index 6ea1300a5ac..5a77b09c3b6 100644 --- a/pkg/yqlib/lib.go +++ b/pkg/yqlib/lib.go @@ -268,7 +268,10 @@ func parseSnippet(value string) (*yaml.Node, error) { if len(parsedNode.Node.Content) == 0 { return nil, fmt.Errorf("bad data") } - return unwrapDoc(parsedNode.Node), err + result := unwrapDoc(parsedNode.Node) + result.Line = 0 + result.Column = 0 + return result, err } func recursiveNodeEqual(lhs *yaml.Node, rhs *yaml.Node) bool { diff --git a/pkg/yqlib/lib_test.go b/pkg/yqlib/lib_test.go index fb3d5c776a2..c3e01009114 100644 --- a/pkg/yqlib/lib_test.go +++ b/pkg/yqlib/lib_test.go @@ -38,8 +38,8 @@ var parseSnippetScenarios = []parseSnippetScenario{ Kind: yaml.ScalarNode, Tag: "!!null", Value: "null", - Line: 1, - Column: 1, + Line: 0, + Column: 0, }, }, { @@ -48,8 +48,8 @@ var parseSnippetScenarios = []parseSnippetScenario{ Kind: yaml.ScalarNode, Tag: "!!int", Value: "3", - Line: 1, - Column: 1, + Line: 0, + Column: 0, }, }, { @@ -58,8 +58,8 @@ var parseSnippetScenarios = []parseSnippetScenario{ Kind: yaml.ScalarNode, Tag: "!!str", Value: "cat", - Line: 1, - Column: 1, + Line: 0, + Column: 0, }, }, { @@ -68,8 +68,8 @@ var parseSnippetScenarios = []parseSnippetScenario{ Kind: yaml.ScalarNode, Tag: "!!float", Value: "3.1", - Line: 1, - Column: 1, + Line: 0, + Column: 0, }, }, { @@ -78,8 +78,8 @@ var parseSnippetScenarios = []parseSnippetScenario{ Kind: yaml.ScalarNode, Tag: "!!bool", Value: "true", - Line: 1, - Column: 1, + Line: 0, + Column: 0, }, }, }