diff --git a/_test/extra.txt b/_test/extra.txt index 63e3c8f..66359bb 100644 --- a/_test/extra.txt +++ b/_test/extra.txt @@ -821,7 +821,7 @@ text" />
//= = = = = = = = = = = = = = = = = = = = = = = =// -66: EOF should be rendered as a newline with an unclosed block +66: EOF should be rendered as a newline with an unclosed block(w/ TAB) //- - - - - - - - -// > ``` > 0 @@ -831,3 +831,14 @@ text" /> //= = = = = = = = = = = = = = = = = = = = = = = =// + +67: EOF should be rendered as a newline with an unclosed block +//- - - - - - - - -// +> ``` +> 0 +//- - - - - - - - -// +++//= = = = = = = = = = = = = = = = = = = = = = = =// diff --git a/text/segment.go b/text/segment.go index 3198d84..83c875b 100644 --- a/text/segment.go +++ b/text/segment.go @@ -44,12 +44,14 @@ func NewSegmentPadding(start, stop, n int) Segment { // Value returns a value of the segment. func (t *Segment) Value(buffer []byte) []byte { + var result []byte if t.Padding == 0 { - return buffer[t.Start:t.Stop] + result = buffer[t.Start:t.Stop] + } else { + result = make([]byte, 0, t.Padding+t.Stop-t.Start+1) + result = append(result, bytes.Repeat(space, t.Padding)...) + result = append(result, buffer[t.Start:t.Stop]...) } - result := make([]byte, 0, t.Padding+t.Stop-t.Start+1) - result = append(result, bytes.Repeat(space, t.Padding)...) - result = append(result, buffer[t.Start:t.Stop]...) if t.EOB && len(result) > 0 && result[len(result)-1] != '\n' { result = append(result, '\n') }+0 +