adobe/brackets — pull request #2185 by gruehle (2012-11-21 21:10:06+00:00)
Title: Use CSSUtils to lookup selector at specified position

The Remote Debugging APIs for retrieving stylesheet information do not always return offsets (the range properties are all marked `optional` in the api). So, instead of relying on the information returned from these APIs, we now use a new CSSUtils function for getting the selector at a specified document position.

Since the `selectorAtPos()` function is called on every cursor move, I opted to do a binary search to find the selector. This doesn't affect performance on small CSS files, but dramatically improves performance on larger ones. I have a test file with ~3000 rules in it, and the binary search was almost 100 times faster when the pos was near the end of the document.

Fixes bug #2173.