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.
ed42b806b1Sagnik Mandal committed on 3/19/2026, 5:02:27 PM· committed by GitHubparent5fb6ead
2 files changedLine totals unavailable