Sublime Forum

Reindent and comments in javascript

#1

Hi,

I’ve mapped the reindent command to a hotkey:

{“keys”: “f12”], “command”: “reindent”, “args”: {“single_line”: false}}

I’ve noticed though that when I’m editing an HTML page (with javascript embedded) that the javascript reindentation for comments doesn’t work, given this text:

function addFields3(event){
        var num = $('.cloned-input3').length; // how many entries do we currently have?
        var newNum = new Number(num+1); // the new number

        // create a new container
        var container = $('#clone3-1').clone().attr('id','clone3-' +newNum);
        // insert the thing into the page
        $("#clone3-"+num).after(container);
//now we need to iterate round the controls and fix the id's
fixFields($('#clone3-'+newNum).contents(), newNum);
        // enable the "remove" button
        $('#btnDel').attr('disabled','');
        return false;
 }

I would have expected the reindent command to change it to look like this:

function addFields3(event){
        var num = $('.cloned-input3').length; // how many entries do we currently have?
        var newNum = new Number(num+1); // the new number

        // create a new container
        var container = $('#clone3-1').clone().attr('id','clone3-' +newNum);
        // insert the thing into the page
        $("#clone3-"+num).after(container);
        //now we need to iterate round the controls and fix the id's
        fixFields($('#clone3-'+newNum).contents(), newNum);
        // enable the "remove" button
        $('#btnDel').attr('disabled','');
        return false;
 }

or something similar. Am I missing something? Is there a setting that disallows the reindentation of comments?

Although it’s not a major problem, it’s an itch that I keep having to scratch manually.

Thanks for any help or ideas.

0 Likes