mirror of
https://github.com/sharkdp/bat.git
synced 2024-12-30 02:08:53 +01:00
Use ↹
character if tab-width == 1.
This commit is contained in:
parent
ecd862d9ff
commit
8fa8f44706
@ -11,6 +11,8 @@ contexts:
|
||||
scope: support.function.show-nonprintable.space
|
||||
- match: "├─*┤"
|
||||
scope: constant.character.escape.show-nonprintable.tab
|
||||
- match: "↹"
|
||||
scope: constant.character.escape.show-nonprintable.tab
|
||||
- match: ""
|
||||
scope: keyword.operator.show-nonprintable.newline
|
||||
- match: "␍"
|
||||
|
@ -36,13 +36,7 @@ pub fn expand_tabs(line: &str, width: usize, cursor: &mut usize) -> String {
|
||||
pub fn replace_nonprintable(input: &mut Vec<u8>, output: &mut Vec<u8>, tab_width: usize) {
|
||||
output.clear();
|
||||
|
||||
let tab_width = if tab_width == 0 {
|
||||
4
|
||||
} else if tab_width == 1 {
|
||||
2
|
||||
} else {
|
||||
tab_width
|
||||
};
|
||||
let tab_width = if tab_width == 0 { 4 } else { tab_width };
|
||||
|
||||
for chr in input {
|
||||
match *chr {
|
||||
@ -50,9 +44,13 @@ pub fn replace_nonprintable(input: &mut Vec<u8>, output: &mut Vec<u8>, tab_width
|
||||
b' ' => output.extend_from_slice("•".as_bytes()),
|
||||
// tab
|
||||
b'\t' => {
|
||||
output.extend_from_slice("├".as_bytes());
|
||||
output.extend_from_slice("─".repeat(tab_width - 2).as_bytes());
|
||||
output.extend_from_slice("┤".as_bytes());
|
||||
if tab_width == 1 {
|
||||
output.extend_from_slice("↹".as_bytes());
|
||||
} else {
|
||||
output.extend_from_slice("├".as_bytes());
|
||||
output.extend_from_slice("─".repeat(tab_width - 2).as_bytes());
|
||||
output.extend_from_slice("┤".as_bytes());
|
||||
}
|
||||
}
|
||||
// new line
|
||||
b'\n' => output.extend_from_slice("".as_bytes()),
|
||||
|
Loading…
Reference in New Issue
Block a user