Repository: Textualize/textual
File: src/textual/widgets/_list_view.py (Python)

Code before:
        """Remove last ListItem from ListView or
           Remove ListItem from ListView by index

        Args:
            index: index of ListItem to remove from ListView

        Returns:
            An awaitable that yields control to the event loop until
                the DOM has been updated to reflect item being removed.
        """
        if index is None:
            await_remove = self.query("ListItem").last().remove()
        else:
            await_remove = self.query("ListItem")[index].remove()
        return await_remove

    def remove_items(self, indices: Iterable[int]) -> AwaitRemove:
        """Remove ListItems from ListView by indices

        Args:
            indices: index(s) of ListItems to remove from ListView

        Returns:
            An awaitable object that waits for the direct children to be removed. 
        """
        if len(self._nodes) == len(indices):
            return self.clear()

        items_to_remove = []
        for index in indices:
            items_to_remove.append(self.query("ListItem")[index])

        await_remove = self.app._remove_nodes(items_to_remove, self)
        return await_remove

    def action_select_cursor(self) -> None:
        """Select the current item in the list."""
        selected_child = self.highlighted_child
        if selected_child is None:
            return
        self.post_message(self.Selected(self, selected_child))

    def action_cursor_down(self) -> None:
        """Highlight the next item in the list."""
        candidate = _widget_navigation.find_next_enabled(
            self._nodes,
            anchor=self.index,
            direction=1,
        )
        if self.index is not None and candidate is not None and candidate < self.index:
            return  # Avoid wrapping around.

Review comment (suggestion):
If there are two items in the `ListView` and the developer passed `[0, 0]` as the `indices` this will have unintended consequences.

Code after:
        """Remove last ListItem from ListView or
           Remove ListItem from ListView by index

        Args:
            index: index of ListItem to remove from ListView

        Returns:
            An awaitable that yields control to the event loop until
                the DOM has been updated to reflect item being removed.
        """
        if index is None:
            await_remove = self.query("ListItem").last().remove()
        else:
            await_remove = self.query("ListItem")[index].remove()
        return await_remove

    def remove_items(self, indices: Iterable[int]) -> AwaitRemove:
        """Remove ListItems from ListView by indices

        Args:
            indices: index(s) of ListItems to remove from ListView

        Returns:
            An awaitable object that waits for the direct children to be removed.
        """
        items = self.query("ListItem")
        items_to_remove = []
        for index in indices:
            items_to_remove.append(items[index])

        await_remove = self.app._remove_nodes(items_to_remove, self)
        return await_remove

    def action_select_cursor(self) -> None:
        """Select the current item in the list."""
        selected_child = self.highlighted_child
        if selected_child is None:
            return
        self.post_message(self.Selected(self, selected_child))

    def action_cursor_down(self) -> None:
        """Highlight the next item in the list."""
        candidate = _widget_navigation.find_next_enabled(
            self._nodes,
            anchor=self.index,
            direction=1,
        )
        if self.index is not None and candidate is not None and candidate < self.index:
            return  # Avoid wrapping around.

        self.index = candidate