Sublime Forum

set_view_index fails silently when index invalid

#1

I noticed that window.set_view_index will fail silently if the supplied index is invalid. Well, to be specific, I only tested the supplied index being greater than the next available index. For example, if I use set_view_index(view, 1, 6) to move a view to the second group but that group has only two views open, the call will fail silently (ie, the view doesn’t get moved and no error is displayed in the console). But if I check the num_views in the group and adjust my desired index accordingly, it works. So the onus is on the caller to get the index right.

I’d like to suggest that set_view_index make that decision. If I pass an index that is beyond the “next” index, set_view_index should just make the view the last one. It seems better to have that logic internal than to require every plugin to make the decision. The same could be said for indexes less than 0…just put the view at zero and be done with it.

Thoughts?

0 Likes