aboutsummaryrefslogtreecommitdiff
path: root/toys/pending
diff options
context:
space:
mode:
Diffstat (limited to 'toys/pending')
-rw-r--r--toys/pending/fmt.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/toys/pending/fmt.c b/toys/pending/fmt.c
index 64df69da..a3d30f02 100644
--- a/toys/pending/fmt.c
+++ b/toys/pending/fmt.c
@@ -74,15 +74,15 @@ static void fmt_line(char **pline, long len)
while (idx<len && !isspace(line[idx])) idx++;
line[idx++] = 0;
count = utf8len(word);
- if (TT.pos+count>=TT.width) newline();
+ if (TT.pos+count+!!TT.pos>=TT.width) newline();
// When indenting a new line, preserve tab/space mixture of input
if (!TT.pos) {
- TT.pos = TT.level-1;
+ TT.pos = TT.level;
if (indent) printf("%.*s", indent, line);
- }
- printf(" %s"+!(TT.pos!=TT.level-1), word);
- TT.pos += count+1;
+ } else count++;
+ printf(" %s"+!(TT.pos!=TT.level), word);
+ TT.pos += count;
while (isspace(line[idx])) idx++;
}
}