lib/utils/cssSections.js
function(content, pos, isBackward) {
			// possible case: editor reported that current syntax is
			// CSS, but it’s actually a HTML document (either `style` tag or attribute)
			var offset = 0;
			var subrange = this.styleTagRange(content, pos);
			if (subrange) {
				offset = subrange.start;
				pos -= subrange.start;
				content = subrange.substring(content);
			}

			var rules = this.findAllRules(content);
			var ctxRule = this.matchEnclosingRule(rules, pos);

			if (ctxRule) {
				return ctxRule.shift(offset);
			}

			for (var i = 0, il = rules.length; i < il; i++) {
				if (rules[i].start > pos) {
					return rules[isBackward && i > 0 ? i - 1 : i].shift(offset);
				}
			}
		}
function(content, pos, isBackward) {
			// possible case: editor reported that current syntax is
			// CSS, but it’s actually a HTML document (either `style` tag or attribute)
			var offset = 0;
			var subrange = this.styleTagRange(content, pos);
			if (subrange) {
				offset = subrange.start;
				pos -= subrange.start;
				content = subrange.substring(content);
			}

			var rules = this.findAllRules(content);
			var ctxRule = this.matchEnclosingRule(rules, pos);

			if (ctxRule) {
				return ctxRule.shift(offset);
			}

			for (var i = 0, il = rules.length; i < il; i++) {
				if (rules[i].start > pos) {
					return rules[isBackward && i > 0 ? i - 1 : i].shift(offset);
				}
			}
		}
function ( content , pos , isBackward ) { // possible case: editor reported that current syntax is // CSS, but it’s actually a HTML document (either `style` tag or attribute) var offset = 0 ; var subrange = this . styleTagRange ( content , pos ) ; if ( subrange ) { offset = subrange . start ; pos -= subrange . start ; content = subrange . substring ( content ) ; } var rules = this . findAllRules ( content ) ; var ctxRule = this . matchEnclosingRule ( rules , pos ) ; if ( ctxRule ) { return ctxRule . shift ( offset ) ; } for ( var i = 0 , il = rules . length ; i < il ; i ++ ) { if ( rules [ i ] . start > pos ) { return rules [ isBackward && i > 0 ? i - 1 : i ] . shift ( offset ) ; } } }
Locates CSS rule next or before given position
@param  {String}  content    CSS content
@param  {Number}  pos        Search start position
@param  {Boolean} isBackward Search backward (find previous rule insteaf of next one)
@return {Range}
Locates CSS rule next or before given position