Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ string_expand(char *dst, size_t dstlen, const char *src, int srclen, int tabsize

if (expanded + size >= dstlen - 1)
expanded = dstlen - size - 1;
memcpy(dst + size, " ", expanded);
memset(dst + size, ' ', expanded);
size += expanded;
} else if (isspace((unsigned char)c) || iscntrl((unsigned char)c)) {
dst[size++] = ' ';
Expand Down
47 changes: 47 additions & 0 deletions test/tigrc/tab-size-test
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/sh

. libtest.sh

export LINES=8

printf 'left\tright\n\tleading\none\t\ttwo\n12345678\tboundary\n' > stdin

steps ':save-display tabs.screen'

for tab_size in 8 9 16 32; do
tigrc <<EOF
set tab-size = $tab_size
EOF

test_tig
sed -n '1,4p' tabs.screen > "tabs-$tab_size"
assert_equals stderr < /dev/null
done

assert_equals tabs-8 strict <<EOF
left right
leading
one two
12345678 boundary
EOF

assert_equals tabs-9 strict <<EOF
left right
leading
one two
12345678 boundary
EOF

assert_equals tabs-16 strict <<EOF
left right
leading
one two
12345678 boundary
EOF

assert_equals tabs-32 strict <<EOF
left right
leading
one two
12345678 boundary
EOF
Loading