ls: make sure current builder is available in JSON output

While lsBuilder has a field called Current that gets lost
because the embedded struct implements custom MarshalJSON method.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2025-05-12 22:30:44 -07:00
parent c398e2a224
commit a3180cbf3d
+11 -1
View File
@@ -213,7 +213,17 @@ type lsContext struct {
}
func (c *lsContext) MarshalJSON() ([]byte, error) {
return json.Marshal(c.Builder)
// can't marshal c.Builder directly because Builder type has custom MarshalJSON
dt, err := json.Marshal(c.Builder.Builder)
if err != nil {
return nil, err
}
var m map[string]any
if err := json.Unmarshal(dt, &m); err != nil {
return nil, err
}
m["Current"] = c.Builder.Current
return json.Marshal(m)
}
func (c *lsContext) Name() string {