From e4ec62569b055058d1ee716a02fa9d72d585fd70 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Thu, 26 Mar 2020 13:52:20 +0100 Subject: stdlib: Fix punc and whitespace in shell_docs Fix so that a newline leading with a whitespace is not rendered with a starting whitespace. Fix so that any punctuation will not be put at the start of a newline. --- lib/stdlib/src/shell_docs.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/stdlib') diff --git a/lib/stdlib/src/shell_docs.erl b/lib/stdlib/src/shell_docs.erl index f22604f204..0e52f28d1b 100644 --- a/lib/stdlib/src/shell_docs.erl +++ b/lib/stdlib/src/shell_docs.erl @@ -613,8 +613,10 @@ render_words(Words,[_,types|State],Pos,Ind,Acc,Cols) -> render_words([Word|T],State,Pos,Ind,Acc,Cols) when is_binary(Word) -> WordLength = string:length(Word), NewPos = WordLength + Pos, + %% We do not want to add a newline if this word is only a punctuation + IsPunct = is_tuple(re:run(Word,"^\\W$")), if - NewPos > (Cols - 10 - Ind) -> + NewPos > (Cols - 10 - Ind), Word =/= <<>>, not IsPunct -> %% Word does not fit, time to add a newline and also pad to Indent level render_words(T,State,WordLength+Ind+1,Ind,[[[pad(Ind), Word]]|Acc],Cols); true -> -- cgit v1.2.1