Skip to content

Commit b16f9a3

Browse files
authored
Merge pull request #894 from gwenn/no_color
Check NO_COLOR environment variable
2 parents caa53cd + f5dc9be commit b16f9a3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/config.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,15 @@ impl Config {
149149

150150
/// Tell if colors should be enabled.
151151
///
152-
/// By default, they are except if stdout is not a TTY.
152+
/// By default, they are except if stdout is not a TTY or NO_COLOR
153+
/// environment variable is set.
153154
#[must_use]
154155
pub fn color_mode(&self) -> ColorMode {
156+
if self.color_mode == ColorMode::Enabled
157+
&& std::env::var_os("NO_COLOR").is_some_and(|os| !os.is_empty())
158+
{
159+
return ColorMode::Disabled;
160+
}
155161
self.color_mode
156162
}
157163

src/line_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ impl LineBuffer {
878878
true
879879
}
880880

881-
/// Replaces the content between [`start`..`end`] with `text`
881+
/// Replaces the content between `range` with `text`
882882
/// and positions the cursor to the end of text.
883883
pub fn replace<C: ChangeListener>(&mut self, range: Range<usize>, text: &str, cl: &mut C) {
884884
let start = range.start;

0 commit comments

Comments
 (0)