Repository: goccy/go-yaml (go)

Issue:
Yaml repeated nodes are not serialized correctly
Example template:

```yaml
spec:
  importantthing_one: &importantthing_one some stuff goes here
  otherstuff:
    foobar: *importantthing_one
```

I'd expect the output to match the input. In reality this is the output:
```yaml
 1 | spec:
 2 |   importantthing_one: &importantthing_onesome stuff goes here
 3 |   otherstuff:
 4 |     foobar: *importantthing_one
```

The space between the var name and the content has disappeared.

Pull request:
Fix origin buffer for anchor value
fix #169


Patch:
diff --git a/scanner/scanner.go b/scanner/scanner.go
index 4c99612..4ebee85 100644
--- a/scanner/scanner.go
+++ b/scanner/scanner.go
@@ -757,7 +757,7 @@ func (s *Scanner) scan(ctx *Context) (pos int) {
 				continue
 			}
 			s.addBufferedTokenIfExists(ctx)
-			s.progressColumn(ctx, 1)
+			pos-- // to rescan white space at next scanning for adding white space to next buffer.
 			s.isAnchor = false
 			return
 		}


Test patch:
diff --git a/printer/printer_test.go b/printer/printer_test.go
index b20a96a..02a304f 100644
--- a/printer/printer_test.go
+++ b/printer/printer_test.go
@@ -137,3 +137,15 @@ a:
 		p.PrintErrorMessage(src, true)
 	})
 }
+
+func TestPrinter_Anchor(t *testing.T) {
+	expected := `
+anchor: &x 1
+alias: *x`
+	tokens := lexer.Tokenize(expected)
+	var p printer.Printer
+	got := p.PrintTokens(tokens)
+	if expected != got {
+		t.Fatalf("unexpected output: expect:[%s]\n actual:[%s]", expected, got)
+	}
+}