# Refactor selection expansion logic into a separate method \(\#10117\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/9cbde74274950b1259087c425a6c0cb22ac4a5c6)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 9cbde74274950b1259087c425a6c0cb22ac4a5c6

Requested commit: 9cbde74274950b1259087c425a6c0cb22ac4a5c6

Commit: 9cbde74274950b1259087c425a6c0cb22ac4a5c6

Tree: 907e53468b35d17e9690d42a68e71f482e76b28a

Author: Hans

Committer: GitHub

## Message

```
Refactor selection expansion logic into a separate method (#10117)

Release Notes:

- N/A

This commit introduces a new method `range` to calculate the target
range for selection expansion based on the current selection, movement
times, and other parameters. The `expand_selection` method is refactored
to use this new `range` method, simplifying the logic for expanding a
selection and making the code more modular and reusable. The `range`
method encapsulates the logic for calculating the new selection range,
including handling linewise selection and adjustments for surrounding
newlines, making it easier to understand and maintain the selection
expansion functionality.

---------

Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
```

## Parents

- [879f3619664d246ef29f5d4e2e26d297f64b8439](https://git.cafe/gitcafe/zed/commit/879f3619664d246ef29f5d4e2e26d297f64b8439?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/9cbde74274950b1259087c425a6c0cb22ac4a5c6?format=markdown)
