<commit_before>/**
 * Watches an expression to keep history of its states
 * and binds ctrl-z and ctrl-y to undo/redo its states
 */
HistoryFactory.$inject = ['History', '$window', '$timeout'];
export function HistoryFactory(History, $window, $timeout) {
    var KeyOperations = {
        ['Z'.charCodeAt(0)]: History.undo,
        ['Y'.charCodeAt(0)]: History.redo
    };

    return {
        watch: function(expression, scope) {
            $timeout(() => {
                History.watch(expression, scope);
            }, 0, false);
            var onHistoryKey = function(event, cb) {
                var modifier = event.ctrlKey || event.metaKey;

                if (modifier && KeyOperations[event.keyCode]) {
                    cb();
                }
            };
            var onHistoryKeydown = function(event) {
                onHistoryKey(event, () => {
                    event.preventDefault();
                    // action is on keydown becuase command key (event.metakey) on OSX is not detected on keyup events
                    // for some reason.
                    scope.$apply(() => {
                        KeyOperations[event.keyCode].bind(History)(expression, scope);
                    });
                });
            };
            var onHistoryKeyup = function(event) {
                onHistoryKey(event, () => {
                    event.preventDefault();<commit_msg>fix(editor2): fix check spelling shortcut not working within editor<commit_after>/**
 * Watches an expression to keep history of its states
 * and binds ctrl-z and ctrl-y to undo/redo its states
 */
HistoryFactory.$inject = ['History', '$window', '$timeout'];
export function HistoryFactory(History, $window, $timeout) {
    var KeyOperations = {
        ['Z'.charCodeAt(0)]: History.undo,
        ['Y'.charCodeAt(0)]: History.redo
    };

    return {
        watch: function(expression, scope) {
            $timeout(() => {
                History.watch(expression, scope);
            }, 0, false);
            var onHistoryKey = function(event, cb) {
                var modifier = (event.ctrlKey || event.metaKey) && !event.altKey && !event.shiftKey;

                if (modifier && KeyOperations[event.keyCode]) {
                    cb();
                }
            };
            var onHistoryKeydown = function(event) {
                onHistoryKey(event, () => {
                    event.preventDefault();
                    // action is on keydown becuase command key (event.metakey) on OSX is not detected on keyup events
                    // for some reason.
                    scope.$apply(() => {
                        KeyOperations[event.keyCode].bind(History)(expression, scope);
                    });
                });
            };
            var onHistoryKeyup = function(event) {
                onHistoryKey(event, () => {
                    event.preventDefault();
{'fraction_non_alphanumeric': 0.12157534246575342, 'fraction_numerical': 0.002397260273972603, 'mean_word_length': 1.619730941704036, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6125288', 'n_tokens_mistral': 749, 'n_tokens_neox': 714, 'n_words': 183}