<commit_before>window.IndentHelper = (function () {
    var indent = function(textarea, reversed) {
        //////////
        // variable for indent function scope
        var tabCharacter = '    ',
            source,

        //////////
        // private getter
        getSourceInformation = function(textarea) {
            var content        = textarea.value,
                selectionStart = textarea.selectionStart,
                selectionEnd   = textarea.selectionEnd,
                selectedString = content.substring(selectionStart, selectionEnd);

            return {
                element:         textarea,
                content:         content,
                selectionStart:  selectionStart,
                selectionEnd:    selectionEnd,
                selectionString: selectedString
            };
        },

        getReplaceeInformation = function() {
            var start   = source.content.lastIndexOf('\n', source.selectionStart - 1),
                end     = source.content.indexOf('\n', source.selectionEnd),
                content = source.content.substring(start, end);

            end = end == -1 ? source.content.length - 1 : end;

            return {
                start:   start,
                end:     end,
                content: content
            };
        },

        //////////
        // helper
        replaceString = function(start, end, indentedString) {
            source.element.value = source.content.substring(0, start) + indentedString + source.content.substring(end, source.content.length);
        },

        setTextareaSelection = function(replaceStart, selectionStart, selectionEnd) {
            source.element.selectionStart = selectionStart;
            if(source.element.selectionStart < replaceStart + 1)
                source.element.selectionStart = replaceStart + 1;

            if(selectionEnd < source.element.selectionStart)
                selectionEnd = source.element.selectionStart;
            source.element.selectionEnd = selectionEnd;
        },

        //////////
        // indent or unindent functions
        indentSelectedLine = function() {
            replaceString(source.selectionStart, source.selectionEnd, tabCharacter);
            setTextareaSelection(-1, source.selectionStart + tabCharacter.length, source.selectionStart + tabCharacter.length);
        },

        unindentSelectedLine = function() {
            var removedTabCharacterLength,
                replacee = getReplaceeInformation(),
                replacedRegExp       = /(^|\n)([ ]{1,4})/;

            if(replacee.content.match(replacedRegExp) === null) {
                removedTabCharacterLength = 0;
            } else {
                removedTabCharacterLength = replacee.content.match(replacedRegExp)[2].length;
            }

            replaceString(replacee.start, replacee.end, replacee.content.replace(replacedRegExp, '$1'));
            setTextareaSelection(replacee.start, source.selectionStart - removedTabCharacterLength, source.selectionStart - removedTabCharacterLength);
        },

        indentSelectedLines = function() {
            var replacee = getReplaceeInformation(),
                replacedRegExp       = /(^|\n)(?!\n)/g;

            replaceString(replacee.start, replacee.end, replacee.content.replace(replacedRegExp, "$1"+tabCharacter));
            setTextareaSelection(replacee.start, source.selectionStart + tabCharacter.length, source.selectionEnd + (tabCharacter.length * source.selectionString.match(replacedRegExp).length));
        },

        unindentSelectedLines = function() {
            var replacee = getReplaceeInformation(),
                replacedRegExp       = /(^|\n)([ ]{1,4})/g,
                removedTabs          = replacee.content.match(replacedRegExp),
                removedTabCharacterLength = 0,
                firstTabLength            = 0,
                lastMatchOfSelectedString,
                index,
                value;

            if(removedTabs !== null) {
                lastMatchOfSelectedString = source.selectionString.match('\n[ ]{0,3}$');

                for(index = 0; index < removedTabs.length; index++) {
                    value = removedTabs[index];
                    if(index != removedTabs.length - 1 || !lastMatchOfSelectedString) {
                        removedTabCharacterLength += (value.match(/[ ]+/)[0].length);
                    } else {
                        removedTabCharacterLength += lastMatchOfSelectedString[0].length - 1;
                    }
                }

                if(source.content.substring(replacee.start, source.selectionStart).match(replacedRegExp) !== null) {
                    firstTabLength = removedTabs[0].match(/[ ]+/)[0].length;
                }
            }

            replaceString(replacee.start, replacee.end, replacee.content.replace(replacedRegExp, "$1"));
            setTextareaSelection(replacee.start, source.selectionStart - firstTabLength, source.selectionEnd - removedTabCharacterLength);
        };



        if(document.selection) {
            ////////////
            // for IE //
            ////////////

        } else {
            source = getSourceInformation(textarea);

            if(source.selectionString.match(/\n/) === null) {
                if(reversed)
                    unindentSelectedLine();
                else
                    indentSelectedLine();

            } else {
                if(reversed)
                    unindentSelectedLines();
                else
                    indentSelectedLines();
            }
        }
    };<commit_msg>라인 다중 라인 선택후(마지막 포함하여) tap 하면 에러나는 것 수정<commit_after>window.IndentHelper = (function () {
    var indent = function(textarea, isReversed) {
        //////////
        // variable for indent function scope
        var tabCharacter = '    ',
            source,

        //////////
        // private getter
        getSourceInformation = function(textarea) {
            var content        = textarea.value,
                selectionStart = textarea.selectionStart,
                selectionEnd   = textarea.selectionEnd,
                selectedString = content.substring(selectionStart, selectionEnd);

            return {
                element:         textarea,
                content:         content,
                selectionStart:  selectionStart,
                selectionEnd:    selectionEnd,
                selectionString: selectedString
            };
        },

        getReplaceeInformation = function() {
            var start   = source.content.lastIndexOf('\n', source.selectionStart - 1),
                end     = source.content.indexOf('\n', source.selectionEnd),
                content;

            end     = end == -1 ? source.content.length - 1 : end;
            content = source.content.substring(start, end);
            return {
                start:   start,
                end:     end,
                content: content
            };
        },

        //////////
        // helper
        replaceString = function(start, end, indentedString) {
            source.element.value = source.content.substring(0, start) + indentedString + source.content.substring(end, source.content.length);
        },

        setTextareaSelection = function(replaceStart, selectionStart, selectionEnd) {
            source.element.selectionStart = selectionStart;
            if(source.element.selectionStart < replaceStart + 1)
                source.element.selectionStart = replaceStart + 1;

            if(selectionEnd < source.element.selectionStart)
                selectionEnd = source.element.selectionStart;
            source.element.selectionEnd = selectionEnd;
        },

        //////////
        // indent or unindent functions
        indentSelectedLine = function() {
            replaceString(source.selectionStart, source.selectionEnd, tabCharacter);
            setTextareaSelection(-1, source.selectionStart + tabCharacter.length, source.selectionStart + tabCharacter.length);
        },

        unindentSelectedLine = function() {
            var removedTabCharacterLength,
                replacee = getReplaceeInformation(),
                replacedRegExp       = /(^|\n)([ ]{1,4})/;

            if(replacee.content.match(replacedRegExp) === null) {
                removedTabCharacterLength = 0;
            } else {
                removedTabCharacterLength = replacee.content.match(replacedRegExp)[2].length;
            }

            replaceString(replacee.start, replacee.end, replacee.content.replace(replacedRegExp, '$1'));
            setTextareaSelection(replacee.start, source.selectionStart - removedTabCharacterLength, source.selectionStart - removedTabCharacterLength);
        },

        indentSelectedLines = function() {
            var replacee = getReplaceeInformation(),
                replacedRegExp       = /(^|\n)(?!\n)/g;

            replaceString(replacee.start, replacee.end, replacee.content.replace(replacedRegExp, "$1"+tabCharacter));
            setTextareaSelection(replacee.start, source.selectionStart + tabCharacter.length, source.selectionEnd + (tabCharacter.length * source.selectionString.match(replacedRegExp).length));
        },

        unindentSelectedLines = function() {
            var replacee = getReplaceeInformation(),
                replacedRegExp       = /(^|\n)([ ]{1,4})/g,
                removedTabs          = replacee.content.match(replacedRegExp),
                removedTabCharacterLength = 0,
                firstTabLength            = 0,
                lastMatchOfSelectedString,
                index,
                value;

            if(removedTabs !== null) {
                lastMatchOfSelectedString = source.selectionString.match('\n[ ]{0,3}$');

                for(index = 0; index < removedTabs.length; index++) {
                    value = removedTabs[index];
                    if(index != removedTabs.length - 1 || !lastMatchOfSelectedString) {
                        removedTabCharacterLength += (value.match(/[ ]+/)[0].length);
                    } else {
                        removedTabCharacterLength += lastMatchOfSelectedString[0].length - 1;
                    }
                }

                if(source.content.substring(replacee.start, source.selectionStart).match(replacedRegExp) !== null) {
                    firstTabLength = removedTabs[0].match(/[ ]+/)[0].length;
                }
            }

            replaceString(replacee.start, replacee.end, replacee.content.replace(replacedRegExp, "$1"));
            setTextareaSelection(replacee.start, source.selectionStart - firstTabLength, source.selectionEnd - removedTabCharacterLength);
        };



        if(document.selection) {
            ////////////
            // for IE //
            ////////////

        } else {
            source = getSourceInformation(textarea);

            if(source.selectionString.match(/\n/) === null) {
                if(isReversed)
                    unindentSelectedLine();
                else
                    indentSelectedLine();

            } else {
                if(isReversed)
                    unindentSelectedLines();
                else
                    indentSelectedLines();
            }
        }
    };
{'fraction_non_alphanumeric': 0.10960960960960961, 'fraction_numerical': 0.0047694753577106515, 'mean_word_length': 1.6492746841366401, 'pattern_counts': {'":': 0, '<': 9, '<?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': '1030640', 'n_tokens_mistral': 2816, 'n_tokens_neox': 2658, 'n_words': 454}