summaryrefslogtreecommitdiffstats
path: root/pkg/commands/patch
diff options
context:
space:
mode:
authorHrishikesh Hiraskar <hrishi@enterpret.com>2021-10-02 13:20:26 +0530
committerJesse Duffield <jessedduffield@gmail.com>2021-10-16 21:18:43 +1100
commitb6454755caf6b90c935f986558f4f9ad085b1837 (patch)
tree65704a5fc6436390cf8dbe54428936edb0d9c6ff /pkg/commands/patch
parent36210840962bb448208b6cc628319f994c392075 (diff)
copy selected text to clipboard
Diffstat (limited to 'pkg/commands/patch')
-rw-r--r--pkg/commands/patch/patch_parser.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/pkg/commands/patch/patch_parser.go b/pkg/commands/patch/patch_parser.go
index 4fb8eb68b..4fed00325 100644
--- a/pkg/commands/patch/patch_parser.go
+++ b/pkg/commands/patch/patch_parser.go
@@ -194,6 +194,22 @@ func (p *PatchParser) Render(firstLineIndex int, lastLineIndex int, incLineIndic
return result
}
+// RenderLines returns the 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 ""
+ }
+ return result
+}
+
// GetNextStageableLineIndex takes a line index and returns the line index of the next stageable line
// note this will actually include the current index if it is stageable
func (p *PatchParser) GetNextStageableLineIndex(currentIndex int) int {