def needed_scrolling(self):
        """Return whether scrolling was performed or not.

        Works by checking whether the last selected path
        is appearing on the directory panel or not. If not
        than we scroll it so it appears. In the end, we
        always return whether such scrolling was needed
        (and thus performed) or not, in the form of a
        boolean.
        """
        ### reference useful data/operation

        last_selected_index = self.last_selected_index
        get_selectable_index = self.selectable_paths.index

        ### retrieve indices of paths being displayed

        displayed_indices = [
            get_selectable_index(path_obj.path)
            for path_obj in self.path_objs
            if path_obj.path in self.selectable_paths
        ]

        ### if last selected path is showing (its index is
        ### among the indices of the paths being displayed
        ### in the directory panel), then there's no need
        ### for scrolling, so you can leave the method and
        ### signal you didn't need to scroll by returning
        ### False

        if self.last_selected_index in displayed_indices:
            return False

        ### otherwise, we perform the amount of scrolling
        ### needed to make the last selected path appear
        ### in the directory panel

        ## retrieve index of paths appearing on top and
        ## bottom of the directory panel

        top_index = min(displayed_indices)
        bottom_index = max(displayed_indices)

        ## define amount of scrolling based on position
        ## of last selected index relative to the top index

        scrolling_amount = (
            # we use the difference between the top index
            # and the last selected index if the last
            # selected one comes before the top index
            top_index - last_selected_index
            if last_selected_index < top_index
            # otherwise it means the last selected index
            # appears after the bottom index, so we use
            # the difference between them
            else bottom_index - last_selected_index
        )

        self.paths_deque.rotate(scrolling_amount)

        ### finally, we return True to indicate we
        ### scrolled the paths
        return True
Return whether scrolling was performed or not.

        Works by checking whether the last selected path
        is appearing on the directory panel or not. If not
        than we scroll it so it appears. In the end, we
        always return whether such scrolling was needed
        (and thus performed) or not, in the form of a
        boolean.
        
nodezator/fileman/dirpanel/extraop.py