From 913338de1bd29d0c7b979a5bb8a947a9f6f05c2e Mon Sep 17 00:00:00 2001 From: Gustavo Niemeyer Date: Mon, 1 Jun 2020 16:28:16 +0100 Subject: [PATCH] Also fix wide char handling on inline comments. --- node_test.go | 3 ++- scannerc.go | 11 +++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/node_test.go b/node_test.go index 5fb1c0f8..af011eb0 100644 --- a/node_test.go +++ b/node_test.go @@ -766,7 +766,7 @@ var nodeTests = []struct { }, }, { - "# š\ntrue\n", + "# š\ntrue # š\n", yaml.Node{ Kind: yaml.DocumentNode, Line: 2, @@ -778,6 +778,7 @@ var nodeTests = []struct { Line: 2, Column: 1, HeadComment: "# š", + LineComment: "# š", }}, }, }, { diff --git a/scannerc.go b/scannerc.go index 579ceb1b..2e9cbf97 100644 --- a/scannerc.go +++ b/scannerc.go @@ -2856,13 +2856,12 @@ func yaml_parser_scan_line_comment(parser *yaml_parser_t, token_mark yaml_mark_t return false } skip_line(parser) - } else { - if parser.mark.index >= seen { - if len(text) == 0 { - start_mark = parser.mark - } - text = append(text, parser.buffer[parser.buffer_pos]) + } else if parser.mark.index >= seen { + if len(text) == 0 { + start_mark = parser.mark } + text = read(parser, text) + } else { skip(parser) } }