# Add \`completions.lsp_insert_mode\` setting to control what ranges are replaced when a completion is inserted \(\#27453\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 07a77792c5146ab917843a3208bc70dce2f13d11

Requested commit: 07a77792c5146ab917843a3208bc70dce2f13d11

Commit: 07a77792c5146ab917843a3208bc70dce2f13d11

Tree: 0253a67b4d8ff49c614d293bf0fd10cc980bd320

Author: frederik-uni

Committer: GitHub

## Message

```
Add `completions.lsp_insert_mode` setting to control what ranges are replaced when a completion is inserted (#27453)

This PR adds `completions.lsp_insert_mode` and effectively changes the
default from `"replace"` to `"replace_suffix"`, which automatically
detects whether to use the LSP `replace` range instead of `insert`
range.

`"replace_suffix"` was chosen as a default because it's more
conservative than `"replace_subsequence"`, considering that deleting
text is usually faster and less disruptive than having to rewrite a long
replaced word.

Fixes #27197
Fixes #23395 (again)
Fixes #4816 (again)

Release Notes:

- Added new setting `completions.lsp_insert_mode` that changes what will
be replaced when an LSP completion is accepted. The default is
`"replace_suffix"`, but it accepts 4 values: `"insert"` for replacing
only the text before the cursor, `"replace"` for replacing the whole
text, `"replace_suffix"` that acts like `"replace"` when the text after
the cursor is a suffix of the completion, and `"replace_subsequence"`
that acts like `"replace"` when the text around your cursor is a
subsequence of the completion (similiar to a fuzzy match). Check [the
documentation](https://zed.dev/docs/configuring-zed#LSP-Insert-Mode) for
more information.

---------

Co-authored-by: João Marcos <marcospb19@hotmail.com>
Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
```

## Parents

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

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