Use `↹` character if tab-width == 1.

This commit is contained in:
sharkdp 2018-11-01 19:40:26 +01:00 committed by David Peter
parent ecd862d9ff
commit 8fa8f44706
2 changed files with 10 additions and 10 deletions

View File

@ -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: "␍"

View File

@ -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()),