We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CompletionAtPos
I would've expected the second call to return zero items but it returns an item. Am I doing something wrong?
1 1
package main import ( "context" "fmt" "github.com/hashicorp/hcl-lang/decoder" "github.com/hashicorp/hcl-lang/lang" "github.com/hashicorp/hcl-lang/schema" "github.com/hashicorp/hcl/v2" "github.com/hashicorp/hcl/v2/hclsyntax" ) type PathReader struct { Files map[string]*hcl.File } func (pr *PathReader) PathContext(path lang.Path) (*decoder.PathContext, error) { schema := &schema.BodySchema{ Blocks: map[string]*schema.BlockSchema{"group": {}}, } pathContext := &decoder.PathContext{Schema: schema, Files: pr.Files} return pathContext, nil } func (pr *PathReader) Paths(ctx context.Context) []lang.Path { return []lang.Path{} } func getNumItems(src []byte, pos hcl.Pos) int { file, pDiags := hclsyntax.ParseConfig(src, "example.hcl", hcl.InitialPos) if len(pDiags) > 0 { panic("errors found stop now") } decoder := decoder.NewDecoder(&PathReader{Files: map[string]*hcl.File{"example.hcl": file}}) pathDecoder, err := decoder.Path(lang.Path{}) if err != nil { panic(err) } completions, err := pathDecoder.CompletionAtPos(context.Background(), "example.hcl", pos) if err != nil { panic(err) } return len(completions.List) } func main() { // 1234567 // group{} fmt.Println(getNumItems([]byte("group{}"), hcl.Pos{Line: 1, Column: 3, Byte: 3})) // 12345678 9101112 // group{}\n# c o mment fmt.Println(getNumItems([]byte("group{}\n# comment"), hcl.Pos{Line: 2, Column: 3, Byte: 12})) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I would've expected the second call to return zero items but it returns an item. Am I doing something wrong?
The text was updated successfully, but these errors were encountered: