<commit_before>import ace from 'ace';
import {
  inject,
  inlineView,
  bindable,
  bindingMode
} from 'aurelia-framework';
import {DOM} from 'aurelia-pal';

// retrieve ace's base path from the System config
let base = System.normalizeSync('ace');
base = base.substr(0, base.length - 3);
ace.config.set('basePath', base);

@inject(Element)
@inlineView('<template></template>')
@bindable({ name: 'theme', defaultValue: 'chrome' })
@bindable({ name: 'mode', defaultValue: 'javascript' })
@bindable({ name: 'value', defaultValue: '', defaultBindingMode: bindingMode.twoWay })
export class AceEditor {
  constructor(element) {
    this.element = element;
    element.focus = ::this.focus;
  }

  themeChanged() {
    if (this.editor) {
      this.editor.setTheme(`ace/theme/${this.theme}`);
    }
  }

  modeChanged() {
    if (this.editor) {
      this.editor.getSession().setMode(`ace/mode/${this.mode}`);
    }
  }

  valueChanged() {
    if (this.editor && this.editor.getValue() !== this.value) {
      this.editor.setValue(this.value, -1);
    }
  }

  resize() {
    if (this.editor) {
      this.editor.resize();
    }
  }

  attached() {
    this.editor = ace.edit(this.element);

    // increase horizontal padding<commit_msg>reset undo on file change<commit_after>import ace from 'ace';
import {
  inject,
  inlineView,
  bindable,
  bindingMode
} from 'aurelia-framework';
import {DOM} from 'aurelia-pal';

// retrieve ace's base path from the System config
let base = System.normalizeSync('ace');
base = base.substr(0, base.length - 3);
ace.config.set('basePath', base);

@inject(Element)
@inlineView('<template></template>')
@bindable({ name: 'theme', defaultValue: 'chrome' })
@bindable({ name: 'mode', defaultValue: 'javascript' })
@bindable({ name: 'value', defaultValue: '', defaultBindingMode: bindingMode.twoWay })
export class AceEditor {
  constructor(element) {
    this.element = element;
    element.focus = ::this.focus;
  }

  themeChanged() {
    if (this.editor) {
      this.editor.setTheme(`ace/theme/${this.theme}`);
    }
  }

  modeChanged() {
    if (this.editor) {
      this.editor.getSession().setMode(`ace/mode/${this.mode}`);
    }
  }
  
  resetUndo() {
    this.editor.getSession().setUndoManager(new ace.UndoManager());
  }

  valueChanged() {
    if (this.editor && this.editor.getValue() !== this.value) {
      this.editor.setValue(this.value, -1);
      this.resetUndo();
    }
  }

  resize() {
    if (this.editor) {
      this.editor.resize();
    }
  }

  attached() {
    this.editor = ace.edit(this.element);

    // increase horizontal padding
{'fraction_non_alphanumeric': 0.17148362235067438, 'fraction_numerical': 0.0023121387283236996, 'mean_word_length': 3.4991334488734833, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6847022', 'n_tokens_mistral': 869, 'n_tokens_neox': 857, 'n_words': 173}