<commit_before>var Path = nodeRequire('path');

var _ = require('underscore');
var Files = require('../files');
var beautify = require('js-beautify').js_beautify;
var beautify_css = require('js-beautify').css;
var beautify_html = require('js-beautify').html;
var ace = require('brace');
require('brace/mode/javascript');
require('brace/mode/html');
require('brace/mode/ejs');
require('brace/mode/css');
require('brace/mode/json');
require('brace/mode/text');
require('brace/theme/tomorrow');
require('brace/ext/searchbox');

var modes = {
  ".html": "ejs",
  ".htm": "ejs",
  ".js": "javascript",
  ".css": "css",
  ".json": "json",
  ".txt": "text"
};


module.exports = {
  template: require('./template.html'),

  data: {
    newProject: true
  },

  ready: function() {
    this.sessions = [];

    this.$on('open-file', this.openFile);
    this.$on('save-project-as', this.saveProjectAs);
    this.$on('reformat', this.reformat);
    this.$on('settings-changed', this.updateSettings);

    this.ace = window.ace = ace.edit('editor');
    this.ace.setTheme('ace/theme/tomorrow');
    this.ace.setReadOnly(true);
  },

  methods: {
    openFile: function(fileObject) {
      var session = _.findWhere(this.sessions, {path: fileObject.path});

      if (!session) {
        var doc = ace.createEditSession(fileObject.contents, "ace/mode/" + modes[fileObject.ext]);

        var self = this;
        doc.on('change', function() {
          var file = Files.find(self.$root.files, fileObject.path);
          if (file) file.contents = doc.getValue();
        });

        var session = {
          path: fileObject.path,
          doc: doc
        };<commit_msg>enable preference pane key command from within ace<commit_after>var Path = nodeRequire('path');

var _ = require('underscore');
var Files = require('../files');
var beautify = require('js-beautify').js_beautify;
var beautify_css = require('js-beautify').css;
var beautify_html = require('js-beautify').html;
var ace = require('brace');
require('brace/mode/javascript');
require('brace/mode/html');
require('brace/mode/ejs');
require('brace/mode/css');
require('brace/mode/json');
require('brace/mode/text');
require('brace/theme/tomorrow');
require('brace/ext/searchbox');

var modes = {
  ".html": "ejs",
  ".htm": "ejs",
  ".js": "javascript",
  ".css": "css",
  ".json": "json",
  ".txt": "text"
};


module.exports = {
  template: require('./template.html'),

  data: {
    newProject: true
  },

  ready: function() {
    this.sessions = [];

    this.$on('open-file', this.openFile);
    this.$on('save-project-as', this.saveProjectAs);
    this.$on('reformat', this.reformat);
    this.$on('settings-changed', this.updateSettings);

    this.ace = window.ace = ace.edit('editor');
    this.ace.setTheme('ace/theme/tomorrow');
    this.ace.setReadOnly(true);

    //override default preference pane
    var self = this;
    this.ace.commands.addCommand({
      name: 'Preferences',
      bindKey: {win: 'Ctrl-,',  mac: 'Command-,'},
      exec: function(editor) {
        self.$root.toggleSettingsPane();
      }
    });
  },

  methods: {
    openFile: function(fileObject) {
      var session = _.findWhere(this.sessions, {path: fileObject.path});

      if (!session) {
        var doc = ace.createEditSession(fileObject.contents, "ace/mode/" + modes[fileObject.ext]);

        var self = this;
        doc.on('change', function() {
          var file = Files.find(self.$root.files, fileObject.path);
          if (file) file.contents = doc.getValue();
        });

        var session = {
          path: fileObject.path,
          doc: doc
        };
{'fraction_non_alphanumeric': 0.18934584598399118, 'fraction_numerical': 0.0, 'mean_word_length': 3.2585193889541717, 'pattern_counts': {'":': 12, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1504504', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1156, 'n_words': 221}