def move_to_stash(self, which, where=None):
        if which is not None and where:
            which = str(which)
            stash_regions = self.get_all_stash_regions()
            if stash_regions:
                prev_regions = [r for r in stash_regions if self.view.substr(r) < which]
                next_regions = [r for r in stash_regions if self.view.substr(r) >= which]
                if next_regions:
                    next = next_regions[0]
                else:
                    next = prev_regions[-1]
                self.move_to_region(next)
            else:
                self.move_to_file(1)
        elif isinstance(which, int):
            stashes = self.get_all_stash_regions()
            if stashes:
                if len(stashes) >= which:
                    self.move_to_region(self.view.line(stashes[which - 1]))
                else:
                    self.move_to_region(self.view.line(stashes[-1]))
dataset/ETHPy150Open SublimeGit/SublimeGit/sgit/status.py/GitStatusMoveCmd.move_to_stash/original