sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Completion in pubspec.yaml is not completing top-level properties

Open sigurdm opened this issue 1 year ago • 3 comments

At least for me, the top-level completers in the pubspec don't work. eg.

name: foo
dep # Completion doesn't give me anything here, I would expect "dependencies"

I'm using VS-code.

I do get completion for individual package names, and for the version constraint:

environment:
  sdk: ^3.2.0

dependencies:
  analyzer: ^6.2.0
  ya # suggests yaml, yaml_edit etc...

One thing though, if I try to insert a new dependency at the top of the list, I don't get completion:

name: pub

environment:
  sdk: ^3.2.0

dependencies:
  ya # No completion here
  analyzer: ^6.2.0

sigurdm avatar Dec 07 '23 10:12 sigurdm

I haven't investigated, but I suspect that this has to do with the way the YAML parser recovers (or fails to recover) from errors in the file.

bwilkerson avatar Dec 07 '23 16:12 bwilkerson

Confirming that it is indeed the case where the YAML parser fails to recover from the errors, and so is unable to parse the incomplete yaml. Hence no suggestions.

@bwilkerson , is there anything we can do here?

keertip avatar Dec 19 '23 23:12 keertip

We could try adding an issue on the yaml parser. I opened https://github.com/dart-lang/yaml/issues/102 and Danny made one fix, perhaps having another concrete use case would get more recovery work done.

bwilkerson avatar Dec 19 '23 23:12 bwilkerson