summaryrefslogtreecommitdiff
path: root/lib/stdlib
diff options
context:
space:
mode:
authorLukas Larsson <lukas@erlang.org>2020-03-26 13:52:20 +0100
committerLukas Larsson <lukas@erlang.org>2020-04-17 10:28:27 +0200
commite4ec62569b055058d1ee716a02fa9d72d585fd70 (patch)
treeb3c37ebf7e172847a20dc68c39d64dfc0a5f0193 /lib/stdlib
parent562a2ef1b5c9ff31e43779ba20da9f24873b021d (diff)
downloaderlang-e4ec62569b055058d1ee716a02fa9d72d585fd70.tar.gz
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.
Diffstat (limited to 'lib/stdlib')
-rw-r--r--lib/stdlib/src/shell_docs.erl4
1 files changed, 3 insertions, 1 deletions
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 ->