# editor: Fix Accessibility Keyboard word completion corrupting text \(\#50676\) · gitcafe/zed

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

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

Visibility: public

Requested revision: ed42b806b148c54b52977533194779b466b298b5

Requested commit: ed42b806b148c54b52977533194779b466b298b5

Commit: ed42b806b148c54b52977533194779b466b298b5

Tree: ef1829a9a368a57aed00586da4597e23a932554a

Author: Sagnik Mandal

Committer: GitHub

## Message

```
editor: Fix Accessibility Keyboard word completion corrupting text (#50676)

When typing with the macOS Accessibility Keyboard and clicking a word
completion suggestion, text was corrupted in several ways.

macOS sends `insertText:replacementRange:` when a completion is
selected. The replacement range was passed to
`selection_replacement_ranges` using the wrong offset type, causing
incorrect delta calculation for multi-cursor scenarios. Additionally,
`backspace` was called unconditionally even when the replacement range
was empty (as with the trailing space the Accessibility Keyboard
appends), deleting the last character of every completed word. Finally,
an empty replacement range in a multi-cursor context carries a stale
cursor position from macOS's single-cursor view of the buffer, so it is
now ignored and text is inserted at each cursor's actual position
instead.

Closes #38052

Release Notes:

- Fixed text corruption when using macOS Accessibility Keyboard word
completion.
```

## Parents

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

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