Home Download Buy Blog Forum Support

set_view_index fails silently when index invalid

set_view_index fails silently when index invalid

Postby phillip.koebbe on Sun Feb 26, 2012 9:27 pm

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.

-- Phillip

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 5 guests