on master help sign in
Use `↹` character if tab-width == 1.
commit8fa8f4470697f2308222bec542dca9dafc831d32 authorsharkdp <davidpeter@web.de> dateThu 1 Nov 2018, 19:40 (8 years ago) parentecd862d
2 files changed+10−10
assets/syntaxes/show-nonprintable.sublime-syntax+2 src/preprocessor.rs+8−10
assets/syntaxes/show-nonprintable.sublime-syntax+2
@@ -11,6 +11,8 @@ contexts:
1111 scope: support.function.show-nonprintable.space
1212 - match: "├─*┤"
1313 scope: constant.character.escape.show-nonprintable.tab
14+ - match: "↹"
15+ scope: constant.character.escape.show-nonprintable.tab
1416 - match: "␤"
1517 scope: keyword.operator.show-nonprintable.newline
1618 - match: "␍"
src/preprocessor.rs+8−10
@@ -36,13 +36,7 @@ pub fn expand_tabs(line: &str, width: usize, cursor: &mut usize) -> String {
3636pub fn replace_nonprintable(input: &mut Vec<u8>, output: &mut Vec<u8>, tab_width: usize) {
3737 output.clear();
3838
39− let tab_width = if tab_width == 0 {
40− 4
41− } else if tab_width == 1 {
42− 2
43− } else {
44− tab_width
45− };
39+ let tab_width = if tab_width == 0 { 4 } else { tab_width };
4640
4741 for chr in input {
4842 match *chr {
@@ -50,9 +44,13 @@ pub fn replace_nonprintable(input: &mut Vec<u8>, output: &mut Vec<u8>, tab_width
5044 b' ' => output.extend_from_slice("•".as_bytes()),
5145 // tab
5246 b'\t' => {
53− output.extend_from_slice("├".as_bytes());
54− output.extend_from_slice("─".repeat(tab_width - 2).as_bytes());
55− output.extend_from_slice("┤".as_bytes());
47+ if tab_width == 1 {
48+ output.extend_from_slice("↹".as_bytes());
49+ } else {
50+ output.extend_from_slice("├".as_bytes());
51+ output.extend_from_slice("─".repeat(tab_width - 2).as_bytes());
52+ output.extend_from_slice("┤".as_bytes());
53+ }
5654 }
5755 // new line
5856 b'\n' => output.extend_from_slice("␤".as_bytes()),