ternjs / tern_for_sublime

Sublime Text package adding Tern support
MIT License
803 stars 54 forks source link

reverse `Region`s may not get handled properly #30

Closed fronx closed 10 years ago

fronx commented 10 years ago

The plugin is unaware of the fact that a Region's a is not necessarily a lower number than its b. For reverse selections, a > b holds. (Ignoring the = case here, since it doesn't make a difference.)

Is this worth fixing?

fronx commented 10 years ago

Okay, I went through all instances of comparisons involving a and b, and it looks like (at least) most Regions can't have been based on reverse selections. The only case I'm not sure about is is_js_file.

fronx commented 10 years ago

I haven't been able to construct a case where this is an issue. Sorry for the noise.

marijnh commented 10 years ago

Some of these are not logically sane -- when getting regions from a selection, it should pick a max/min rather than assuming .a < .b. See attached patch.

fronx commented 10 years ago

@marijnh Oooh, very cool. :]