<commit_before>"use strict";

angular.module('arethusa.inlineComments').directive('inlineComment', [
    'state',
    function(state) {
        return {
            restrict: 'A',
            scope: {
                token:"=commentToken"
            },
            link: function(scope, element, attrs) {
                scope.comment = scope.token.comment? scope.token.comment : '';

                //TODO: undo function
                // - set state to previous value
                // - set scope.comment to previous value
                // - how does redo work?

                function undoFn(tkn, cmt) {
                    var token = tkn;
                    var comment = cmt;
                    return function() {
                        scope.comment = comment;
                        state.change(token,'comment',comment)
                    }
                }

                function preExecFn(cmt) {
                    var comment = cmt;
                    return function() {
                        scope.comment = comment;
                    }
                }

                scope.updateState = function() {
                    state.change(scope.token,'comment',scope.comment,undoFn(scope.token,scope.token.comment),preExecFn(scope.comment));
                };
            },
            templateUrl: 'js/arethusa.inline_comments/templates/inline_comment.html'
        };
    }
]);<commit_msg>Remove TODO comment<commit_after>"use strict";

angular.module('arethusa.inlineComments').directive('inlineComment', [
    'state',
    function(state) {
        return {
            restrict: 'A',
            scope: {
                token:"=commentToken"
            },
            link: function(scope, element, attrs) {
                scope.comment = scope.token.comment? scope.token.comment : '';

                function undoFn(tkn, cmt) {
                    var token = tkn;
                    var comment = cmt;
                    return function() {
                        scope.comment = comment;
                        state.change(token,'comment',comment)
                    }
                }

                function preExecFn(cmt) {
                    var comment = cmt;
                    return function() {
                        scope.comment = comment;
                    }
                }

                scope.updateState = function() {
                    state.change(scope.token,'comment',scope.comment,undoFn(scope.token,scope.token.comment),preExecFn(scope.comment));
                };
            },
            templateUrl: 'js/arethusa.inline_comments/templates/inline_comment.html'
        };
    }
]);
{'fraction_non_alphanumeric': 0.10514541387024609, 'fraction_numerical': 0.0, 'mean_word_length': 1.1902040816326531, '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': '2274088', 'n_tokens_mistral': 669, 'n_tokens_neox': 616, 'n_words': 109}