src/LiveDevelopment/Agents/EditAgent.js
function _findChangedCharacters(oldValue, value) {
        if (oldValue === value) {
            return undefined;
        }
        var length = oldValue.length;
        var index = 0;

        // find the first character that changed
        var i;
        for (i = 0; i < length; i++) {
            if (value[i] !== oldValue[i]) {
                break;
            }
        }
        index += i;
        value = value.substr(i);
        length -= i;

        // find the last character that changed
        for (i = 0; i < length; i++) {
            if (value[value.length - 1 - i] !== oldValue[oldValue.length - 1 - i]) {
                break;
            }
        }
        length -= i;
        value = value.substr(0, value.length - i);

        return { from: index, to: index + length, text: value };
    }
function _findChangedCharacters(oldValue, value) {
        if (oldValue === value) {
            return undefined;
        }
        var length = oldValue.length;
        var index = 0;

        // find the first character that changed
        var i;
        for (i = 0; i < length; i++) {
            if (value[i] !== oldValue[i]) {
                break;
            }
        }
        index += i;
        value = value.substr(i);
        length -= i;

        // find the last character that changed
        for (i = 0; i < length; i++) {
            if (value[value.length - 1 - i] !== oldValue[oldValue.length - 1 - i]) {
                break;
            }
        }
        length -= i;
        value = value.substr(0, value.length - i);

        return { from: index, to: index + length, text: value };
    }
function _findChangedCharacters ( oldValue , value ) { if ( oldValue === value ) { return undefined ; } var length = oldValue . length ; var index = 0 ; // find the first character that changed var i ; for ( i = 0 ; i < length ; i ++ ) { if ( value [ i ] !== oldValue [ i ] ) { break ; } } index += i ; value = value . substr ( i ) ; length -= i ; // find the last character that changed for ( i = 0 ; i < length ; i ++ ) { if ( value [ value . length - 1 - i ] !== oldValue [ oldValue . length - 1 - i ] ) { break ; } } length -= i ; value = value . substr ( 0 , value . length - i ) ; return { from : index , to : index + length , text : value } ; }
Find changed characters
@param {string} old value
@param {string} changed value
@return {from, to, text}
Find changed characters