(b []byte, d diffMode)
| 200 | } |
| 201 | |
| 202 | func (s textList) formatCompactTo(b []byte, d diffMode) ([]byte, textNode) { |
| 203 | s = append(textList(nil), s...) // Avoid mutating original |
| 204 | |
| 205 | // Determine whether we can collapse this list as a single line. |
| 206 | n0 := len(b) // Original buffer length |
| 207 | var multiLine bool |
| 208 | for i, r := range s { |
| 209 | if r.Diff == diffInserted || r.Diff == diffRemoved { |
| 210 | multiLine = true |
| 211 | } |
| 212 | b = append(b, r.Key...) |
| 213 | if r.Key != "" { |
| 214 | b = append(b, ": "...) |
| 215 | } |
| 216 | b, s[i].Value = r.Value.formatCompactTo(b, d|r.Diff) |
| 217 | if _, ok := s[i].Value.(textLine); !ok { |
| 218 | multiLine = true |
| 219 | } |
| 220 | if r.Comment != nil { |
| 221 | multiLine = true |
| 222 | } |
| 223 | if i < len(s)-1 { |
| 224 | b = append(b, ", "...) |
| 225 | } |
| 226 | } |
| 227 | // Force multi-lined output when printing a removed/inserted node that |
| 228 | // is sufficiently long. |
| 229 | if (d == diffInserted || d == diffRemoved) && len(b[n0:]) > maxColumnLength { |
| 230 | multiLine = true |
| 231 | } |
| 232 | if !multiLine { |
| 233 | return b, textLine(b[n0:]) |
| 234 | } |
| 235 | return b, s |
| 236 | } |
| 237 | |
| 238 | func (s textList) formatExpandedTo(b []byte, d diffMode, n indentMode) []byte { |
| 239 | alignKeyLens := s.alignLens( |
nothing calls this directly
no test coverage detected