1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

minor changes

This commit is contained in:
Jesse Duffield
2021-10-16 13:49:40 +11:00
parent b6454755ca
commit 87e9d9bdc2
6 changed files with 24 additions and 26 deletions

View File

@ -546,7 +546,9 @@ func RunLineOutputCmd(cmd *exec.Cmd, onLine func(line string) (bool, error)) err
}
func (c *OSCommand) CopyToClipboard(str string) error {
c.LogCommand(fmt.Sprintf("Copying '%s' to clipboard", utils.TruncateWithEllipsis(str, 40)), false)
escaped := strings.Replace(str, "\n", "\\n", -1)
truncated := utils.TruncateWithEllipsis(escaped, 40)
c.LogCommand(fmt.Sprintf("Copying '%s' to clipboard", truncated), false)
return clipboard.WriteAll(str)
}

View File

@ -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,
)
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
}
result := strings.Join(renderedLines, "\n")
if strings.TrimSpace(utils.Decolorise(result)) == "" {
return ""
}
return result
return strings.Join(renderedLines, "\n")
}
// GetNextStageableLineIndex takes a line index and returns the line index of the next stageable line