<commit_before>var Util, DOM;

(function(Util, DOM) {
    'use strict';
    
    DOM.Buffer  = new BufferProto();
    
    function BufferProto() {
        var Storage = DOM.Storage,
            Dialog  = DOM.Dialog,
            Files   = DOM.Files,
            Info    = DOM.CurrentInfo,
            
            CLASS   = 'cut-file',
            
            COPY    = 'copy',
            CUT     = 'cut',
            
            Buffer  = {
                cut     : callIfEnabled.bind(null, cut),
                copy    : callIfEnabled.bind(null, copy),
                clear   : callIfEnabled.bind(null, clear),
                paste   : callIfEnabled.bind(null, paste)
            };
        
        function getNames() {
            var name    = Info.name,
                names   = DOM.getSelectedNames(),
                n       = names.length;
            
            return n ? names : [name];
        }
        
        function addCutClass() {
            var files   = DOM.getActiveFiles();
            
            files.forEach(function(element) {
                DOM.addClass(element, CLASS);
            });
        }
        
        function rmCutClass() {
            var files   = DOM.getActiveFiles();
            
            files.forEach(function(element) {
                DOM.removeClass(element, CLASS);
            });
        }
        
        function isEnabled(callback) {
            Files.get('config', function(error, config) {
                if (error)
                    Dialog.alert(error);
                else
                    callback(config.buffer);
            });
        }
        
        function callIfEnabled(callback) {
             isEnabled(function(is) {
                if (is)
                    callback();
                else
                    Dialog.alert('Buffer disabled in config!');
            });
        }
        
        function copy() {
            var Storage = DOM.Storage,
                names   = getNames(),
                from    = Info.dirPath;
            
            Storage.remove(CUT)
                .set(COPY, {
                    from : from,
                    names: names
                });
        }
        
        function cut() {
            var Storage = DOM.Storage,
                names   = getNames(),
                from    = Info.dirPath;
                
            addCutClass();
            
            Storage.remove(COPY)
                .set(CUT, {
                    from : from,
                    names: names
                });
        }
        
        function clear() {
             Storage.remove(COPY)
                    .remove(CUT);
            
            rmCutClass();
        }
        
        function paste() {
            var copy    = Storage.get.bind(Storage, COPY),
                cut     = Storage.get.bind(Storage, CUT);
            
            Util.exec.parallel([copy, cut], function(error, cp, ct) {
                var data    = {},
                    msg     = 'Path is same!',
                    path    = Info.dirPath;
                
                if (!error && !cp && !ct)
                    error   = 'Buffer is empty!';
                    
                if (error) {
                    DOM.Dialog.alert(error);
                } else if (cp) {
                    data        = Util.json.parse(cp);
                    data.to     = path;
                    
                    if (data.from === path)
                        Dialog.alert(msg);
                    else
                        DOM.copyFiles(data);
                
                } else if (ct) {
                    data        = Util.json.parse(ct);
                    data.to     = path;
                    
                    if (data.from === path)
                        Dialog.alert(msg);
                    else
                        DOM.moveFiles(data);
                }
                
                clear();
            });
        }
        
        return Buffer;
    }
})(Util, DOM);
<commit_msg>fix(buffer) copy, or cut, after cut, do not prevent previous cutting<commit_after>var Util, DOM;

(function(Util, DOM) {
    'use strict';
    
    DOM.Buffer  = new BufferProto();
    
    function BufferProto() {
        var Storage = DOM.Storage,
            Dialog  = DOM.Dialog,
            Files   = DOM.Files,
            Info    = DOM.CurrentInfo,
            
            CLASS   = 'cut-file',
            
            COPY    = 'copy',
            CUT     = 'cut',
            
            Buffer  = {
                cut     : callIfEnabled.bind(null, cut),
                copy    : callIfEnabled.bind(null, copy),
                clear   : callIfEnabled.bind(null, clear),
                paste   : callIfEnabled.bind(null, paste)
            };
        
        function getNames() {
            var name    = Info.name,
                names   = DOM.getSelectedNames(),
                n       = names.length;
            
            return n ? names : [name];
        }
        
        function addCutClass() {
            var files   = DOM.getActiveFiles();
            
            files.forEach(function(element) {
                DOM.addClass(element, CLASS);
            });
        }
        
        function rmCutClass() {
            var files   = DOM.getByClassAll(CLASS),
                array   = Util.slice(files);
            
            array.forEach(function(element) {
                DOM.removeClass(element, CLASS);
            });
        }
        
        function isEnabled(callback) {
            Files.get('config', function(error, config) {
                if (error)
                    Dialog.alert(error);
                else
                    callback(config.buffer);
            });
        }
        
        function callIfEnabled(callback) {
             isEnabled(function(is) {
                if (is)
                    callback();
                else
                    Dialog.alert('Buffer disabled in config!');
            });
        }
        
        function copy() {
            var Storage = DOM.Storage,
                names   = getNames(),
                from    = Info.dirPath;
            
            clear();
            
            Storage.remove(CUT)
                .set(COPY, {
                    from : from,
                    names: names
                });
        }
        
        function cut() {
            var Storage = DOM.Storage,
                names   = getNames(),
                from    = Info.dirPath;
                
            clear();
            addCutClass();
            
            Storage
                .set(CUT, {
                    from : from,
                    names: names
                });
        }
        
        function clear() {
             Storage.remove(COPY)
                    .remove(CUT);
            
            rmCutClass();
        }
        
        function paste() {
            var copy    = Storage.get.bind(Storage, COPY),
                cut     = Storage.get.bind(Storage, CUT);
            
            Util.exec.parallel([copy, cut], function(error, cp, ct) {
                var data    = {},
                    msg     = 'Path is same!',
                    path    = Info.dirPath;
                
                if (!error && !cp && !ct)
                    error   = 'Buffer is empty!';
                    
                if (error) {
                    DOM.Dialog.alert(error);
                } else if (cp) {
                    data        = Util.json.parse(cp);
                    data.to     = path;
                    
                    if (data.from === path)
                        Dialog.alert(msg);
                    else
                        DOM.copyFiles(data);
                
                } else if (ct) {
                    data        = Util.json.parse(ct);
                    data.to     = path;
                    
                    if (data.from === path)
                        Dialog.alert(msg);
                    else
                        DOM.moveFiles(data);
                }
                
                clear();
            });
        }
        
        return Buffer;
    }
})(Util, DOM);

{'fraction_non_alphanumeric': 0.0956574185765983, 'fraction_numerical': 0.0, 'mean_word_length': 0.7841618248332257, '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': '727557', 'n_tokens_mistral': 2036, 'n_tokens_neox': 1911, 'n_words': 394}