SublimeJSCSFormatter icon indicating copy to clipboard operation
SublimeJSCSFormatter copied to clipboard

Make formatting only selected area.

Open pofigizm opened this issue 9 years ago • 5 comments

What do you think?

pofigizm avatar Apr 29 '15 08:04 pofigizm

I think people would enjoy being able to format a selected region. I'm not sure JSCS would work with this if you select a region that isn't valid code on it's own. @mikesherov @markelog, any ideas?

elicwhite avatar Apr 29 '15 15:04 elicwhite

Esprima would throw an error and jscs would propagate it, you could check for the parser error and do the nop otherwise autofix it.

markelog avatar Apr 29 '15 16:04 markelog

this is a tough problem. Not sure how best to proceed...

mikesherov avatar Apr 29 '15 16:04 mikesherov

Oleg's solution seems to work well. You could possibly pipe the selected text into jscs or construct a temp file with the selected text and feed the filename in.

On Wed, Apr 29, 2015 at 12:05 PM, Mike Sherov [email protected] wrote:

this is a tough problem. Not sure how best to proceed...

— Reply to this email directly or view it on GitHub https://github.com/TheSavior/SublimeJSCSFormatter/issues/28#issuecomment-97481733 .

mrjoelkemp avatar Apr 29 '15 16:04 mrjoelkemp

Come to think of it, there is another way to try, take user selection, if it has parser bugs - iteratively increase the selection until it stops showing parser bugs, limit that increase to two-three lines so it wouldn't take too much, but don't show the new selection to the user, try to autofix that, otherwise do the nop.

markelog avatar Apr 29 '15 16:04 markelog