Bytes returns the string that should be written to disk when the line array is saved
()
| 170 | // Bytes returns the string that should be written to disk when |
| 171 | // the line array is saved |
| 172 | func (la *LineArray) Bytes() []byte { |
| 173 | b := new(bytes.Buffer) |
| 174 | // initsize should provide a good estimate |
| 175 | b.Grow(int(la.initsize + 4096)) |
| 176 | for i, l := range la.lines { |
| 177 | b.Write(l.data) |
| 178 | if i != len(la.lines)-1 { |
| 179 | if la.Endings == FFDos { |
| 180 | b.WriteByte('\r') |
| 181 | } |
| 182 | b.WriteByte('\n') |
| 183 | } |
| 184 | } |
| 185 | return b.Bytes() |
| 186 | } |
| 187 | |
| 188 | // newlineBelow adds a newline below the given line number |
| 189 | func (la *LineArray) newlineBelow(y int) { |