<commit_before>define(function (require) {
  "use strict";

  var AppInit                   = brackets.getModule("utils/AppInit");
  var DocumentManager           = brackets.getModule("document/DocumentManager");
  var EditorManager             = brackets.getModule("editor/EditorManager");
  var FileUtils                 = brackets.getModule("file/FileUtils");
  var MainViewManager           = brackets.getModule("view/MainViewManager");
  var PreferencesManager        = brackets.getModule("preferences/PreferencesManager");

  var packageJSON               = require("text!package.json");
  var COMMAND_ID                = JSON.parse(packageJSON).name;
  var prefs                     = PreferencesManager.getExtensionPrefs(COMMAND_ID);
  var stateManager              = PreferencesManager.stateManager.getPrefixedSystem(COMMAND_ID);

  var CacheHandler              = require("modules/CacheHandler");
  var DiffHandler               = require("modules/DiffHandler");

  /* 
   * @private 
   * @method _loadDocumentHistory
   * @description Loads the documents history from state if it exists.
   * @params {CodeMirrorDocument} codeMirrorDoc Code Mirror document to set the history to
   */
  function _loadDocumentHistory(codeMirrorDoc, wasModified, cachedDoc) {
    var path = MainViewManager.getCurrentlyViewedPath();      
    var documentHistoriesInState = stateManager.get("documentHistories");

    if (documentHistoriesInState) {
      var history = documentHistoriesInState[path];

      if (history) {        
        history = JSON.parse(history);
        
        if (wasModified) {
          console.log("was modifed outside of Brackets, should invalidate redos and and do so that one CTRL+Z brings doc to cachedDoc-state");
        }
        
        codeMirrorDoc.setHistory(history);
      }
    } 
  }

  /* 
   * @private 
   * @method _loadDocumentHistory
   * @description Diff the current document against cached file, then load the history
   * @param {Editor} editor Editor that gains focus<commit_msg>Modify history if document was modified outside of Brackets<commit_after>define(function (require) {
  "use strict";

  var AppInit                   = brackets.getModule("utils/AppInit");
  var DocumentManager           = brackets.getModule("document/DocumentManager");
  var EditorManager             = brackets.getModule("editor/EditorManager");
  var FileUtils                 = brackets.getModule("file/FileUtils");
  var MainViewManager           = brackets.getModule("view/MainViewManager");
  var PreferencesManager        = brackets.getModule("preferences/PreferencesManager");

  var packageJSON               = require("text!package.json");
  var COMMAND_ID                = JSON.parse(packageJSON).name;
  var prefs                     = PreferencesManager.getExtensionPrefs(COMMAND_ID);
  var stateManager              = PreferencesManager.stateManager.getPrefixedSystem(COMMAND_ID);

  var CacheHandler              = require("modules/CacheHandler");
  var DiffHandler               = require("modules/DiffHandler");

  /* 
   * @private 
   * @method _loadDocumentHistory
   * @description Loads the documents history from state if it exists.
   * @params {CodeMirrorDocument} codeMirrorDoc Code Mirror document to set the history to
   */
  function _loadDocumentHistory(codeMirrorDoc, wasModified, cachedDoc) {
    var path = MainViewManager.getCurrentlyViewedPath();      
    var documentHistoriesInState = stateManager.get("documentHistories");

    if (documentHistoriesInState) {
      var history = documentHistoriesInState[path];

      if (history) {        
        history = JSON.parse(history);
        
        // Set editor value to cachedDoc before setting history and then set the value back to the modified file
        // so that the history applies to the modified document too.
        if (wasModified) {
          
          var currentDoc = codeMirrorDoc.getValue();
          codeMirrorDoc.setValue(cachedDoc);
          codeMirrorDoc.setHistory(history);
          codeMirrorDoc.setValue(currentDoc);
          
        } else {
          codeMirrorDoc.setHistory(history);          
        }
        
      }
    } 
  }

  /* 
   * @private 
   * @method _loadDocumentHistory
   * @description Diff the current document against cached file, then load the history
   * @param {Editor} editor Editor that gains focus
{'fraction_non_alphanumeric': 0.08411214953271028, 'fraction_numerical': 0.0, 'mean_word_length': 2.671966527196653, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7596847', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1073, 'n_words': 277}