<commit_before>/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */
/*global define, $, brackets, window */

define(function (require, exports, module) {
    "use strict";

    var CommandManager = brackets.getModule("command/CommandManager"),
        EditorManager = brackets.getModule("editor/EditorManager"),
        DocumentManager = brackets.getModule("document/DocumentManager"),
        EditorUtils = brackets.getModule("editor/EditorUtils"),
        Menus = brackets.getModule("command/Menus"),
        COMMAND_ID = "me.drewh.jsbeautify";

    require('beautify');
    require('beautify-html');
	require('beautify-css');

    var indent_size = 1;
    var indent_char = '\t';


    var autoFormat = function () {

        var txt = DocumentManager.getCurrentDocument().getText();
        var editor = EditorManager.getCurrentFullEditor();
        var fileType = EditorUtils.getModeFromFileExtension(DocumentManager.getCurrentDocument().url);
        var cursor = editor.getCursorPos();
        var scroll = editor.getScrollPos();


        if (fileType === "javascript") {
            var formattedText = js_beautify(txt, {
                indent_size: indent_size,
                indent_char: indent_char,
                reserve_newlines: true,
                jslint_happy: true,
                keep_array_indentation: true,
                space_before_conditional: true
            });
        } else if (fileType === 'htmlmixed') {

            var formattedText = style_html(txt, {
                indent_size: indent_size,
                indent_char: indent_char
            });
        } else if (fileType === 'css' || fileType === 'less') {

            var formattedText = css_beautify(txt, {
                indent_size: indent_size,
                indent_char: indent_char
            });

        } else {
            alert('Could not determine file type');
        }


        DocumentManager.getCurrentDocument().setText(formattedText);
        var newCursorPos = editor.getCursorPos();

        editor.setCursorPos(cursor);
        editor.setScrollPos(scroll.x, scroll.y);
    };

    CommandManager.register("Beautify", COMMAND_ID, autoFormat);

    var menu = Menus.getMenu(Menus.AppMenuBar.EDIT_MENU);
    menu.addMenuItem(COMMAND_ID, [{
        key: "Ctrl-Shift-F",
        platform: "win"},
                                                                                          {
        key: "Ctrl-Shift-F",
        platform: "mac"}]);

});<commit_msg>use editor settings for beautify<commit_after>/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */
/*global define, $, brackets, window */

define(function (require, exports, module) {
    "use strict";

    var CommandManager = brackets.getModule("command/CommandManager"),
        EditorManager = brackets.getModule("editor/EditorManager"),
        Editor = brackets.getModule("editor/Editor").Editor,
        DocumentManager = brackets.getModule("document/DocumentManager"),
        EditorUtils = brackets.getModule("editor/EditorUtils"),
        Menus = brackets.getModule("command/Menus"),
        COMMAND_ID = "me.drewh.jsbeautify";

    require('beautify');
    require('beautify-html');
    require('beautify-css');

    var _useTabs = Editor.getUseTabChar();
    var _indent_size = Editor.getTabSize();

    if (_useTabs) {
        var _indent_char = '\t';
    } else {
        var _indent_char = ' ';
    }

    var autoFormat = function () {

        var txt = DocumentManager.getCurrentDocument().getText();
        var editor = EditorManager.getCurrentFullEditor();
        var fileType = EditorUtils.getModeFromFileExtension(DocumentManager.getCurrentDocument().url);
        //var fileType = editor.getModeForDocument()
        var cursor = editor.getCursorPos();
        var scroll = editor.getScrollPos();

        if (fileType === "javascript") {

            var formattedText = js_beautify(txt, {
                indent_size: _indent_size,
                indent_char: _indent_char,
                reserve_newlines: true,
                jslint_happy: true,
                keep_array_indentation: false,
                space_before_conditional: true
            });
        } else if (fileType === 'htmlmixed') {

            var formattedText = style_html(txt, {
                indent_size: _indent_size,
                indent_char: _indent_char
            });

        } else if (fileType === 'css' || fileType === 'less') {

            var formattedText = css_beautify(txt, {
                indent_size: _indent_size,
                indent_char: _indent_char
            });

        } else {
            alert('Could not determine file type');
        }

        DocumentManager.getCurrentDocument().setText(formattedText);
        var newCursorPos = editor.getCursorPos();

        editor.setCursorPos(cursor);
        editor.setScrollPos(scroll.x, scroll.y);
    };

    CommandManager.register("Beautify", COMMAND_ID, autoFormat);

    var menu = Menus.getMenu(Menus.AppMenuBar.EDIT_MENU);
    menu.addMenuItem(COMMAND_ID, [{
        key: "Ctrl-Shift-F",
        platform: "win"},
                                                                                                                  {
        key: "Ctrl-Shift-F",
        platform: "mac"}
    ]);

});
{'fraction_non_alphanumeric': 0.11567025621982918, 'fraction_numerical': 0.0012996658002228, 'mean_word_length': 2.124709976798144, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '427421', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1419, 'n_words': 287}