mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-13 00:56:25 -04:00
Stop treating tool errors as command log boundaries when copying git output
A non-indented error line followed by indented context matches the shape of an action plus command, so copied git output was truncated mid-block. Only treat the next line as a new log entry when it looks like a lazygit command rather than any indented text.
This commit is contained in:
parent
a2b21978c6
commit
799deabfef
|
|
@ -146,12 +146,16 @@ func isStartOfNewCommandLogEntry(lines []string, i int) bool {
|
|||
if isCopyToClipboardLogLine(lines[j]) {
|
||||
continue
|
||||
}
|
||||
return strings.HasPrefix(lines[j], " ")
|
||||
return isLazygitCommandLogLine(lines[j])
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func isLazygitCommandLogLine(line string) bool {
|
||||
return isCopyToClipboardLogLine(line) || strings.HasPrefix(line, " git ")
|
||||
}
|
||||
|
||||
func (gui *Gui) LogCommand(cmdStr string, commandLine bool) {
|
||||
if gui.Views.Extras == nil {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -38,6 +38,28 @@ func TestGitOutputBlocksIncludeIndentedStderr(t *testing.T) {
|
|||
assert.Equal(t, []string{"Push\n git push\n\nGit output:\n at foo.go:10\n at bar.go:20\nhook failed"}, gitOutputBlocksFromCommandLogLines(lines, gitOutputHeader))
|
||||
}
|
||||
|
||||
func TestGitOutputBlocksIncludeToolErrorWithIndentedContext(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
lines := []string{
|
||||
"Push",
|
||||
" git push",
|
||||
gitOutputHeader,
|
||||
"Error: validation failed",
|
||||
" line 42: syntax error",
|
||||
"more output",
|
||||
"Stage file",
|
||||
" git add foo",
|
||||
gitOutputHeader,
|
||||
"second command output",
|
||||
}
|
||||
|
||||
assert.Equal(t, []string{
|
||||
"Push\n git push\n\nGit output:\nError: validation failed\n line 42: syntax error\nmore output",
|
||||
"Stage file\n git add foo\n\nGit output:\nsecond command output",
|
||||
}, gitOutputBlocksFromCommandLogLines(lines, gitOutputHeader))
|
||||
}
|
||||
|
||||
func TestGitOutputBlocksSkipCopyNotifications(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue