"view.sel()" returns a Selection rather than RegionSet. #26

Closed
skuroda opened this Issue Apr 27, 2013 · 7 comments

Comments

Projects
None yet
2 participants

skuroda commented Apr 27, 2013

The API documentation specifies the return of a RegionSet.

Initial forum issue.
http://www.sublimetext.com/forum/viewtopic.php?t=12075


Not a member of the org yet so can't add the labels. If someone could do that, or add me to the org I'd appreciate it. Of course, remove this part of the issue after doing that 😄

Owner

FichteFoll commented Apr 27, 2013

Created a new Documentation category with a different color for this since it's not that ST-related regarding internals. Not sure about a "Type" label though so I just chose to add none which seems to be the best option here.

Regarding the org, I think we need some kind of a policy here because we obviously can't just add anyone (since you'll be granted push-access to numerous other plugins within this org as well). Maybe we need a different rank for the org that only grants access to this repo but I don't know if that's possible. That's why I didn't add you as of now (it's not like I knew how or whether I am able to do this in the first place, lol).

skuroda commented Apr 28, 2013

No problem, I don't know how much I'd be back to check this anyways. I'll just leave it to you folks who are already a port of the org. Anyways, I'm not 100% sure it should be classified as a documentation issue. Selection is not documented anywhere. In addition, in ST2, these returned RegionSets. Guess we'll just have to see what jps does.

Owner

FichteFoll commented Apr 28, 2013

Considering that sublime_api internally refers to these as "selection" as well makes me think that this is an intended change and just didn't make it to the docs (I mean, it does make sense).

And since you don't instantiate these objects manually this would only make a difference when using isinstance() to check parameter validity or something which is also rarely an issue.

skuroda commented Apr 28, 2013

Makes sense. As far as I can tell, the only "difference" between the two is the implementation of the contains method. For selection, this always returns None rather than True or False as one might expect. That aside, I think many users would agree that documentation (API related or otherwise) needs an update, including removing the old ST1 docs.

Owner

FichteFoll commented Apr 28, 2013

class Selection(object):
    # ...
    def contains(self, region):
        sublime_api.view_selection_contains(self.view_id, region.a, region.b)

Not sure why but I'm getting the feeling I know why this is always returning None. ;) Seems like you discovered a real bug.

skuroda commented Apr 29, 2013

To be fair I didn't find it. All credit to the forum poster. But I figured it would be a good thing to post here too. It got buried on the forum already, and I feel API issues are things that would come up for someone else eventually. :)

skuroda commented May 16, 2013

Documentation updated and call fixed in build 3034

skuroda closed this May 16, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment