# terminal: Expose \`selection\` in context and add \`keep_selection_on_copy\` setting \(\#33491\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 5c88e9c66b0618707da21063254c8a8332110d43

Requested commit: 5c88e9c66b0618707da21063254c8a8332110d43

Commit: 5c88e9c66b0618707da21063254c8a8332110d43

Tree: b5175a6b1809c6e1d00b7c412dc5bbb4602e7cca

Author: chico ferreira

Committer: GitHub

## Message

````
terminal: Expose `selection` in context and add `keep_selection_on_copy` setting (#33491)

Closes #21262

Introduces a new setting `keep_selection_on_copy`, which controls
whether the current text selection is preserved after copying in the
terminal. The default behavior remains the same (`true`), but setting it
to `false` will clear the selection after the copy operation, matching
VSCode's behavior.

Additionally, the terminal context now exposes a `selection` flag
whenever text is selected.

This allows users to match VSCode and other terminal's smart copy
behavior.

Release Notes:

- Expose `selection` to terminal context when there is text selected in
the terminal
- Add `keep_selection_on_copy` terminal setting. Can be set to false to
clear the text selection when copying text.

**VSCode Behavior Example:**

**settings.json:**
```json
  "terminal": {
    "keep_selection_on_copy": false
  },
```
**keymap.json:**
```json
  {
    "context": "Terminal && selection",
    "bindings": {
      "ctrl-c": "terminal::Copy"
    }
  }
```
````

## Parents

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

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