remove trim() on comments (to keep comment indentation)

This commit is contained in:
xdrm-brackets 2018-11-12 15:38:43 +01:00
parent 73b953c35b
commit 69f7cb47b8
2 changed files with 10 additions and 10 deletions

View File

@ -74,10 +74,10 @@ func (d *decoder) Decode(v interface{}) error {
// 2. comment // 2. comment
if line[0] == '#' { if line[0] == '#' {
l.Type = COMMENT l.Type = COMMENT
l.Components = []string{strings.Trim(line[1:], " \t")} l.Components = []string{line[1:]}
} else if line[0] == ';' { } else if line[0] == ';' {
l.Type = COLONCOMMENT l.Type = COLONCOMMENT
l.Components = []string{strings.Trim(line[1:], " \t")} l.Components = []string{line[1:]}
} else if line[0] == '}' { } else if line[0] == '}' {
l.Type = SECTIONEND l.Type = SECTIONEND
if len(stack) < 1 { if len(stack) < 1 {

View File

@ -39,16 +39,16 @@ func TestEachLineType(t *testing.T) {
{"#some comment\n", []string{"some comment"}, COMMENT}, {"#some comment\n", []string{"some comment"}, COMMENT},
{"#some\tcomment\n", []string{"some\tcomment"}, COMMENT}, {"#some\tcomment\n", []string{"some\tcomment"}, COMMENT},
{"# some comment \n", []string{"some comment"}, COMMENT}, {"# some comment \n", []string{" some comment"}, COMMENT},
{"# some comment \t\n", []string{"some comment"}, COMMENT}, {"# some comment \t\n", []string{" some comment"}, COMMENT},
{"\t# some comment {\n", []string{"some comment {"}, COMMENT}, {"\t# some comment {\n", []string{" some comment {"}, COMMENT},
{";some comment\n", []string{"some comment"}, COLONCOMMENT}, {";some comment\n", []string{"some comment"}, COLONCOMMENT},
{"; some\tcomment\n", []string{"some\tcomment"}, COLONCOMMENT}, {"; some\tcomment\n", []string{" some\tcomment"}, COLONCOMMENT},
{"; some comment\n", []string{"some comment"}, COLONCOMMENT}, {"; some comment\n", []string{" some comment"}, COLONCOMMENT},
{"; some comment \n", []string{"some comment"}, COLONCOMMENT}, {"; some comment \n", []string{" some comment"}, COLONCOMMENT},
{"; some comment \t\n", []string{"some comment"}, COLONCOMMENT}, {"; some comment \t\n", []string{" some comment"}, COLONCOMMENT},
{"\t; some comment {\n", []string{"some comment {"}, COLONCOMMENT}, {"\t; some comment {\n", []string{" some comment {"}, COLONCOMMENT},
} }
for i, test := range tests { for i, test := range tests {