api-issue-tracker icon indicating copy to clipboard operation
api-issue-tracker copied to clipboard

selection#add is not an alias for selection#toggle

Open arigo opened this issue 5 years ago • 3 comments

Documentation bug. Since at least SU 2017, the documentation for Sketchup::Selection is no longer up-to-date about the methods #add and #remove and #toggle. The documentation says that they are all aliases for one another. However, that's not the case any more; they now behave like their name implies.

Sketchup.active_model.selection.add(Sketchup.active_model.entities.to_a)
19    # for example, if I have 19 entities in total
Sketchup.active_model.selection.add(Sketchup.active_model.entities.to_a)
0     # the 19 entities remain selected (so add != toggle)
Sketchup.active_model.selection.remove(Sketchup.active_model.entities.to_a)
19    # the 19 entities are now unselected
Sketchup.active_model.selection.remove(Sketchup.active_model.entities.to_a)
0     # all entities are already unselected (so remove != toggle)

arigo avatar Nov 09 '20 18:11 arigo

I can find no mention of the change in behavior in the Ruby API release notes.

I do remember all 3 methods acting as aliases back ~ v7 or 8, (and no one liking it.) But I cannot remember when this changed.

DanRathbun avatar Nov 09 '20 18:11 DanRathbun

Yea, I think those comments are very old. I cannot recall this being fixed while I has been working here. I'm guessing it was fixed during the Google era.

thomthom avatar Nov 10 '20 11:11 thomthom

Please update the docs on this. It took me awhile to track down a bug in my code and in turned out the bug was because I had assumed that was written in the docs regarding the selection method aliases was true.

Whaat avatar Jan 24 '23 19:01 Whaat