Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 497340

Summary: Improvements for Format (JSBeautify)
Product: [ECD] Orion Reporter: Curtis Windatt <curtis.windatt.public>
Component: JS ToolsAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Olivier_Thomann
Version: 12.0   
Target Milestone: 13.0   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Curtis Windatt CLA 2016-07-05 13:43:26 EDT
1) 'Format' can be a bit confusing, as it will only affect the selection if there is one.  For reference, VS Code has the same behaviour, but calls the action 'Format Code'.

2) The JSBeautify default settings do not match the default editor settings.  If you format existing files all the tabs end up being replaced with 4 spaces.

3) If you have leading whitespace selected, the formatter will remove it.  This is fine in most cases, but you can end up selecting the newline at the end of a previous line and the formatter puts it all on to one line.
Comment 1 Olivier Thomann CLA 2016-07-05 13:50:39 EDT
For (1), should I rename it to "Format Code" ?

It would be good to "share" editor settings with the formatter. I am not sure how this is feasible in practice. I'll take a look.
Comment 2 Olivier Thomann CLA 2016-07-05 14:26:40 EDT
Delivered changes to adjust default values to be tab and not spaces.
Comment 3 Olivier Thomann CLA 2016-07-12 14:34:31 EDT
Renamed action to "Format Code". Delivered as commit de7d3aad16e60b04e1e13304a846a5666da53933.
Comment 4 Olivier Thomann CLA 2016-07-13 14:16:51 EDT
Curtis, I think I workaround (3). I'll deliver the code. Please check that it improved it. Thanks.
Delivered changes.
Comment 5 Curtis Windatt CLA 2016-07-13 16:49:41 EDT
(In reply to Olivier Thomann from comment #4)
> Curtis, I think I workaround (3). I'll deliver the code. Please check that
> it improved it. Thanks.
> Delivered changes.

If you select the end of one line as well as some later text, everything is still put onto one line.  With your change if you only select the whitespace it isn't deleted, which is an improvement. I'm fine with the current behaviour.