lib/action/selectItem.js
function matchedRangeForCSSProperty(rule, selRange, isBackward) {
		var ranges = findInnerRanges(rule);
		if (isBackward) {
			ranges.reverse();
		}
		
		// return next to selected range, if possible
		var r = utils.find(ranges, function(item) {
			return item.equal(selRange);
		});

		if (r) {
			return ranges[ranges.indexOf(r) + 1];
		}

		// find matched and (possibly) overlapping ranges
		var nested = ranges.filter(function(item) {
			return item.inside(selRange.end);
		});

		if (nested.length) {
			return nested.sort(function(a, b) {
				return a.length() - b.length();
			})[0];
		}

		// return range next to caret
		var test = 
		r = utils.find(ranges, isBackward 
			? function(item) {return item.end < selRange.start;}
			: function(item) {return item.end > selRange.start;}
		);

		if (!r) {
			// can’t find anything, just pick first one
			r = ranges[0];
		}

		return r;
	}
function matchedRangeForCSSProperty(rule, selRange, isBackward) {
		var ranges = findInnerRanges(rule);
		if (isBackward) {
			ranges.reverse();
		}
		
		// return next to selected range, if possible
		var r = utils.find(ranges, function(item) {
			return item.equal(selRange);
		});

		if (r) {
			return ranges[ranges.indexOf(r) + 1];
		}

		// find matched and (possibly) overlapping ranges
		var nested = ranges.filter(function(item) {
			return item.inside(selRange.end);
		});

		if (nested.length) {
			return nested.sort(function(a, b) {
				return a.length() - b.length();
			})[0];
		}

		// return range next to caret
		var test = 
		r = utils.find(ranges, isBackward 
			? function(item) {return item.end < selRange.start;}
			: function(item) {return item.end > selRange.start;}
		);

		if (!r) {
			// can’t find anything, just pick first one
			r = ranges[0];
		}

		return r;
	}
function matchedRangeForCSSProperty ( rule , selRange , isBackward ) { var ranges = findInnerRanges ( rule ) ; if ( isBackward ) { ranges . reverse ( ) ; } // return next to selected range, if possible var r = utils . find ( ranges , function ( item ) { return item . equal ( selRange ) ; } ) ; if ( r ) { return ranges [ ranges . indexOf ( r ) + 1 ] ; } // find matched and (possibly) overlapping ranges var nested = ranges . filter ( function ( item ) { return item . inside ( selRange . end ) ; } ) ; if ( nested . length ) { return nested . sort ( function ( a , b ) { return a . length ( ) - b . length ( ) ; } ) [ 0 ] ; } // return range next to caret var test = r = utils . find ( ranges , isBackward ? function ( item ) { return item . end < selRange . start ; } : function ( item ) { return item . end > selRange . start ; } ) ; if ( ! r ) { // can’t find anything, just pick first one r = ranges [ 0 ] ; } return r ; }
Tries to find matched CSS property and nearest range for selection
@param {CSSRule} rule
@param {Range} selRange
@param {Boolean} isBackward
@returns {Range}
Tries to find matched CSS property and nearest range for selection