YamlDotNet.Editor icon indicating copy to clipboard operation
YamlDotNet.Editor copied to clipboard

Format Document chokes on comments

Open madskristensen opened this issue 11 years ago • 3 comments

It happens when there are comments in the .yml file. The issue happens on this line:

emitter.Emit(parser.Current);

...in this file https://github.com/aaubry/YamlDotNet.Editor/blob/master/YamlDotNetEditor/CommandHandlers/FormatDocumentCommandHandler.cs#L55

So the error happens in the YamlDotNet NuGet package somewhere that can't be fixed from the extension itself.

Repro steps

In a YAML file containing this:

# version format
version: 1.0.{build}

Now invoke the Format Document command (Ctrl+K+D) and you get the error.

madskristensen avatar Feb 04 '15 01:02 madskristensen

The problem must be that the parser is configured to return comments, but comments are not officially part of the YAML document and the emitter does not supports them.

aaubry avatar Feb 04 '15 23:02 aaubry

So perhaps the fix for now is to remove the support for Format Document then?

madskristensen avatar Feb 04 '15 23:02 madskristensen

Not necessarily. Since the parser has support to return comments, it would make sense to support them in the emitter. I added support for comments because it was necessary for this extension, but at the time I did not need to emit comments, so I forgot to add them to the emitter. I will take a look to the code to see what would be required.

aaubry avatar Feb 05 '15 00:02 aaubry