Skip to content

Commit

Permalink
graceful fail for columns=0, #552
Browse files Browse the repository at this point in the history
  • Loading branch information
cmhughes committed Jul 18, 2024
1 parent fed474e commit 5596d5a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions LatexIndent/Wrap.pm
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,13 @@ sub text_wrap_comment_blocks {
# call the text wrapping routine
my $columns = ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{columns};

# fail gracefully if columns == 0
if ($columns==0){
$logger->warn("* textWrapOptions: columns is set to 0, can't text wrap with this");
${ ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{comments} }{wrap} = 0;
return;
}

#
# text wrap comment blocks
#
Expand Down
2 changes: 2 additions & 0 deletions test-cases/text-wrap/issue-552.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
% 1
% 2
2 changes: 2 additions & 0 deletions test-cases/text-wrap/issue-552.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
WARN: textWrapOptions: columns is set to 0, can't text wrap with this
No objects found.
4 changes: 4 additions & 0 deletions test-cases/text-wrap/issue-552.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
modifyLineBreaks:
textWrapOptions:
comments:
wrap: 1
5 changes: 5 additions & 0 deletions test-cases/text-wrap/text-wrap-remove-PLB.sh
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ latexindent.pl -s -m -r -l issue-502.yaml,addruler2.yaml issue-502.tex -o=+-mod1
latexindent.pl -s -m -r -l issue-502a.yaml,addruler2.yaml issue-502a.tex -o=+-mod1

latexindent.pl -s -l issue-506.yaml -m issue-506.tex -o=+-mod1

latexindent.pl -l issue-552.yaml -m issue-552.tex -s
cp indent.log issue-552.txt
perl -p0i -e 's/.*?(WARN)/$1/s' issue-552.txt
perl -p0i -e 's/INFO:.*//s' issue-552.txt
set +x
[[ $gitStatus == 1 ]] && git status
[[ $noisyMode == 1 ]] && makenoise
Expand Down

0 comments on commit 5596d5a

Please sign in to comment.