Skip to content

Commit

Permalink
v.util: add diff tool color support detection (tested on linux and fr…
Browse files Browse the repository at this point in the history
…eebsd) (#21244)
  • Loading branch information
ttytm authored Apr 10, 2024
1 parent b832b96 commit 48800d4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions vlib/v/util/diff/diff.v
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ pub fn find_working_diff_command() !string {
return error('could not find specified VDIFF_TOOL ${diffcmd}')
}
if p.exit_code == 0 { // success
if diffcmd in ['gdiff', 'diff'] {
if p.output.contains('GNU diffutils') && env_diffopts == '' {
return '${diffcmd} --color=always'
}
}
if diffcmd in ['code', 'code.cmd'] {
// there is no guarantee that the env opts exist
// or include `-d`, so (harmlessly) add it
Expand Down

0 comments on commit 48800d4

Please sign in to comment.