mirror of
https://github.com/sharkdp/bat.git
synced 2025-03-20 01:28:49 +00:00
Merge pull request #1440 from Enselic/fix-1438-newline-can-be-added-even-if-style-plain
Don't add artificial newline to last line if --style=plain
This commit is contained in:
commit
cc7b89faf8
@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
## Bugfixes
|
## Bugfixes
|
||||||
|
|
||||||
- only print themes hint in interactive mode (`bat --list-themes`), see #1439 (@rsteube)
|
- If the last line doesn't end with a newline character, don't add it if `--style=plain`, see #1438 (@Enselic)
|
||||||
|
- Only print themes hint in interactive mode (`bat --list-themes`), see #1439 (@rsteube)
|
||||||
- Make ./tests/syntax-tests/regression_test.sh work on recent versions of macOS, see #1443 (@Enselic)
|
- Make ./tests/syntax-tests/regression_test.sh work on recent versions of macOS, see #1443 (@Enselic)
|
||||||
|
|
||||||
## Other
|
## Other
|
||||||
|
@ -72,7 +72,7 @@ pub fn replace_nonprintable(input: &[u8], tab_width: usize) -> String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// line feed
|
// line feed
|
||||||
'\x0A' => output.push('␊'),
|
'\x0A' => output.push_str("␊\x0A"),
|
||||||
// carriage return
|
// carriage return
|
||||||
'\x0D' => output.push('␍'),
|
'\x0D' => output.push('␍'),
|
||||||
// null
|
// null
|
||||||
|
@ -91,9 +91,6 @@ impl<'a> Printer for SimplePrinter<'a> {
|
|||||||
if self.config.show_nonprintable {
|
if self.config.show_nonprintable {
|
||||||
let line = replace_nonprintable(line_buffer, self.config.tab_width);
|
let line = replace_nonprintable(line_buffer, self.config.tab_width);
|
||||||
write!(handle, "{}", line)?;
|
write!(handle, "{}", line)?;
|
||||||
if line_buffer.last() == Some(&b'\n') {
|
|
||||||
writeln!(handle)?;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
handle.write_all(line_buffer)?
|
handle.write_all(line_buffer)?
|
||||||
};
|
};
|
||||||
@ -463,7 +460,7 @@ impl<'a> Printer for InteractivePrinter<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if line.bytes().next_back() != Some(b'\n') {
|
if !self.config.style_components.plain() && line.bytes().next_back() != Some(b'\n') {
|
||||||
writeln!(handle)?;
|
writeln!(handle)?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -813,3 +813,17 @@ fn show_all_mode() {
|
|||||||
.stdout("hello·world␊\n├──┤␍␀␇␈␛")
|
.stdout("hello·world␊\n├──┤␍␀␇␈␛")
|
||||||
.stderr("");
|
.stderr("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn plain_mode_does_not_add_nonexisting_newline() {
|
||||||
|
bat()
|
||||||
|
.arg("--paging=never")
|
||||||
|
.arg("--color=never")
|
||||||
|
.arg("--decorations=always")
|
||||||
|
.arg("--style=plain")
|
||||||
|
.arg("single-line.txt")
|
||||||
|
.assert()
|
||||||
|
.success()
|
||||||
|
.stdout("Single Line");
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -175,4 +175,4 @@
|
|||||||
[38;2;117;113;94m\u{ad}[0m[38;2;249;38;114m␊[0m
|
[38;2;117;113;94m\u{ad}[0m[38;2;249;38;114m␊[0m
|
||||||
[38;2;117;113;94m\u{ae}[0m[38;2;249;38;114m␊[0m
|
[38;2;117;113;94m\u{ae}[0m[38;2;249;38;114m␊[0m
|
||||||
[38;2;249;38;114m␊[0m
|
[38;2;249;38;114m␊[0m
|
||||||
[38;2;248;248;242mHere's[0m[38;2;102;217;239m·[0m[38;2;248;248;242ma[0m[38;2;102;217;239m·[0m[38;2;248;248;242mline[0m[38;2;102;217;239m·[0m[38;2;248;248;242mwith[0m[38;2;102;217;239m·[0m[38;2;248;248;242mmultiple[0m[38;2;102;217;239m·[0m[38;2;248;248;242mcharacters.[0m
|
[38;2;248;248;242mHere's[0m[38;2;102;217;239m·[0m[38;2;248;248;242ma[0m[38;2;102;217;239m·[0m[38;2;248;248;242mline[0m[38;2;102;217;239m·[0m[38;2;248;248;242mwith[0m[38;2;102;217;239m·[0m[38;2;248;248;242mmultiple[0m[38;2;102;217;239m·[0m[38;2;248;248;242mcharacters.[0m[38;2;249;38;114m␊[0m
|
||||||
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user