Skip to content

Commit

Permalink
fix: off one errors in GetNodeForPosition
Browse files Browse the repository at this point in the history
  • Loading branch information
qvalentin committed Nov 10, 2024
1 parent 3e39bb6 commit 3c2d914
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/util/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func GetNodeForPosition(node *yamlv3.Node, position lsp.Position) *yamlv3.Node {
return nil
}

if node.Value != "" && node.Line == int(position.Line+1) && node.Column <= int(position.Character-1) {
if node.Value != "" && node.Line == int(position.Line+1) && node.Column <= int(position.Character+1) {
return node
}

Expand Down
3 changes: 2 additions & 1 deletion internal/util/yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func TestGetNodeForPosition(t *testing.T) {
t.Fatalf("error parsing YAML: %v", err)
}

result := GetNodeForPosition(&node, lsp.Position{Line: 9, Character: 3})
result := GetNodeForPosition(&node, lsp.Position{Line: 8, Character: 3})
assert.NotNil(t, result)
assert.Equal(t, "repository", result.Value)
}

0 comments on commit 3c2d914

Please sign in to comment.