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

Code before:

        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._prune(*items_to_remove, parent=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

    def action_cursor_up(self) -> None:
        """Highlight the previous item in the list."""
        candidate = _widget_navigation.find_next_enabled(
            self._nodes,

Review comment (suggestion):
I wanted to avoid this, because widgets should be able to be written with the public API only.

We have a `remove_children` method, which seems most appropriate, but it takes a selector rather than a list of widgets.

How about `remove_children` is updated to accept a sequence of widgets, so you could do this:

```python
sellf.remove_children(items_to_remove)
```

Code after:

        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 = [items[index] for index in indices]
        await_remove = self.remove_children(items_to_remove)
        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

    def action_cursor_up(self) -> None:
        """Highlight the previous item in the list."""
        candidate = _widget_navigation.find_next_enabled(
            self._nodes,
            anchor=self.index,
            direction=-1,
        )