Accent keys makes cursor jump backwards in Safari

A wrong behaviour on Safari is observed when entering characters like ˜, ˆ after a highlighted character. The behaviour can be reproduced with a basic setup:

  1. Put the cursor at the end of line 2 (make sure the bracket(s) are highlighted)
  2. Press + n on Mac
    The same process applies for line 5 with + i

The cursor jumps backwards. After that, it sometimes produces unexpected behaviours on any future actions.

The wrong behaviour is observed only when entering accent characters directly from a keyboard but not when pasting them. Tested on Safari 16.2 (18614.


Somehow, on my Safari (15.6.1, on macOS 16.6) this problem does not occur. The keys do start a composition (underlined, can combine with another char typed after) but the cursor stays in the right place and everything seems to work properly.

The keyboard source matters, and the new example supports both English (US) and English (GB).


1 Like

That just shows the same text twice, how is the example text keyboard-language related?

That just shows the same text twice

Both texts are similar (e.g. ˜ entered with US, ~ entered with GB keyboard), but not the same. Were you able to reproduce the issue this time?

how is the example text keyboard-language related?

I’m not sure either. I was unable to narrow it down to anything specifically.

Some keyboard layouts use compositions, i.e. press an accent and then press a vowel to combine them, like French. That might be what’s happening here.

An extreme example is the Vietnamese keyboard where typing “ER” results into ẻ.

I’ve got this down to a reproducible case. The combination of a marker decoration and syntax highlighting does it:


In Safari, with an IME enabled (say, Pinyin or Hiragana), place the cursor inside the parentheses in console.log() and type a character. The cursor jumps back a few characters and composition ends abruptly. ⌥ + n on a US or GB keyboard will do it too.

Thanks, that made it easy to reproduce. This patch should help.