CodeFormatter icon indicating copy to clipboard operation
CodeFormatter copied to clipboard

CodeFormatterPrint sometimes produces unparsable code

Open Masterxilo opened this issue 9 years ago • 1 comments

I'd like to use CodeFormatterPrint to serialize definitions and a canonical but readable way. For this, all the code it produces should, when evaluated, restore the definitions I had in place.

But this does not always work:

ClearAll@f
f[veryveryveryveryveryveryveryverylongname, 
    veryveryveryveryveryveryveryverylongname] /; a > 0 := a;
CodeFormatterPrint@f

produces

f[    
     veryveryveryveryveryveryveryverylongname,
     veryveryveryveryveryveryveryverylongname
 ]
/;
  (a > 0) :=
     a

which cannot be parsed correctly because /; stands on its own.

/; should be at the end of the line above such that the expression is not yet complete.

Masterxilo avatar Aug 08 '16 15:08 Masterxilo

Probably a fix similar to this is needed: https://github.com/lshifr/CodeFormatter/pull/7

Masterxilo avatar Aug 08 '16 16:08 Masterxilo