Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 275443 - Some javascript formatting issues
Summary: Some javascript formatting issues
Status: RESOLVED FIXED
Alias: None
Product: DLTK
Classification: Technology
Component: JavaScript (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: dltk.common-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-05-08 07:36 EDT by Johan Compagner CLA
Modified: 2009-05-12 10:15 EDT (History)
1 user (show)

See Also:


Attachments
JavaScript formatter patch (fixes 2 bugs) (11.45 KB, patch)
2009-05-12 05:53 EDT, Vladimir Belov CLA
no flags Details | Diff
JavaScript formatter patch (replacement) (10.95 KB, patch)
2009-05-12 06:53 EDT, Vladimir Belov CLA
alex.panchenko: iplog+
Details | Diff
JavaScript formatter patch (replacement - 2) (5.55 KB, patch)
2009-05-12 10:15 EDT, Vladimir Belov CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Johan Compagner CLA 2009-05-08 07:36:53 EDT
i have this function:

function test1() {
   editor.setContentByPath("sample.html")

   // Show the editor
}

now i select the body (so between { and } not including })

then press CTRL-SHIFT-F, then i get this:

function test1() {
function test1 () {
    editor.setContentByPath ("sample.html")

    // Show the editor
}

}

so the contents of the complete file (if i had more functions they would appear also in there) is copied into the lines i selected and pressed format for.

second issue is that i loose spaces

/**
 * This  is my greatest function
 */
function test()
{
}

becomes

/**
* This  is my greatest function
*/
function test()
{
}
Comment 1 Vladimir Belov CLA 2009-05-12 05:53:31 EDT
Created attachment 135313 [details]
JavaScript formatter patch (fixes 2 bugs)

Fixed both bugs - formatting fragments and multi-line comments.
Comment 2 Alex Panchenko CLA 2009-05-12 05:59:03 EDT
Hi Johan,

I will commit this patch.

Regards,
Alex
Comment 3 Vladimir Belov CLA 2009-05-12 06:53:15 EDT
Created attachment 135322 [details]
 JavaScript formatter patch (replacement)  

Fixed bug with object literals (it didn't work if property name is not identifier)
Comment 4 Alex Panchenko CLA 2009-05-12 07:13:30 EDT
Committed to HEAD.
Comment 5 Vladimir Belov CLA 2009-05-12 10:15:12 EDT
Created attachment 135350 [details]
JavaScript formatter patch (replacement - 2)

Added new feature: function body may be without braces.