You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I added a line in the middle of a file, and reprinted it, the trailing new line I had disappear. I didn't change any options, but isn't the reuseWhitespace suppose to be sufficient? Is there anything I misunderstood?
Here is the flow:
functionFile(filestring){this.ast=recast.parse(filestring,{esprima: require('babel-core')});}File.prototype.print=function(){returnrecast.print(this.ast).code;};// Some modifications on the treefs.writeFile(filePath,file.print(),callback);
Nothing fancy, the print works perfectly, I got the line I wanted, but the trailing new line of my file disappeared. Any clues?
Ah, options.reuseWhitespace is just for indentation whitespace (spaces and possibly tabs), though its meaning could possibly be extended its meaning to include lines as well.
In this case, I think the culprit is printStatementSequence, which tries to reuse the whitespace in between statements in a list of reprinted statements, but generally trims away any leading/trailing space before/after the first/last statements.
Activity
benjamn commentedon Jul 14, 2015
Ah,
options.reuseWhitespaceis just for indentation whitespace (spaces and possibly tabs), though its meaning could possibly be extended its meaning to include lines as well.In this case, I think the culprit is
printStatementSequence, which tries to reuse the whitespace in between statements in a list of reprinted statements, but generally trims away any leading/trailing space before/after the first/last statements.I think I can fix that pretty quickly (today).
Thanks for the report!
AugustinLF commentedon Jul 14, 2015
That would be awesome, thanks a lot!