Fix calculation of selected item (for not drawing it) in formspec

The previous code did not work when the list did not start at index 0
of the inventory list (issue #779).