diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-10-16 13:49:40 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-10-16 21:18:43 +1100 |
commit | 87e9d9bdc21ebb38727a04c9df7ef5aadc1eba84 (patch) | |
tree | c7d812f28c0ebe6b11407a1dbed0b313859e74e7 /pkg/commands/patch | |
parent | b6454755caf6b90c935f986558f4f9ad085b1837 (diff) |
minor changes
Diffstat (limited to 'pkg/commands/patch')
-rw-r--r-- | pkg/commands/patch/patch_parser.go | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/pkg/commands/patch/patch_parser.go b/pkg/commands/patch/patch_parser.go index 4fed00325..1fefe0748 100644 --- a/pkg/commands/patch/patch_parser.go +++ b/pkg/commands/patch/patch_parser.go @@ -194,20 +194,17 @@ func (p *PatchParser) Render(firstLineIndex int, lastLineIndex int, incLineIndic return result } -// RenderLines returns the coloured string of diff part from firstLineIndex to +// PlainRenderLines returns the non-coloured string of diff part from firstLineIndex to // lastLineIndex -func (p *PatchParser) RenderLines(firstLineIndex, lastLineIndex int) string { - renderedLines := make([]string, lastLineIndex-firstLineIndex+1) - for index := firstLineIndex; index <= lastLineIndex; index++ { - renderedLines[index-firstLineIndex] = p.PatchLines[index].render( - false, false, - ) - } - result := strings.Join(renderedLines, "\n") - if strings.TrimSpace(utils.Decolorise(result)) == "" { - return "" +func (p *PatchParser) PlainRenderLines(firstLineIndex, lastLineIndex int) string { + linesToCopy := p.PatchLines[firstLineIndex : lastLineIndex+1] + + renderedLines := make([]string, len(linesToCopy)) + for index, line := range linesToCopy { + renderedLines[index] = line.Content } - return result + + return strings.Join(renderedLines, "\n") } // GetNextStageableLineIndex takes a line index and returns the line index of the next stageable line |