0

When editing some lines of code in RStudio, that have Spanish accents (eg. á, é...) the text I type appears one space before the cursor position. For example, in:

a <- tibble(b = c("01", "02", "03", "04", "05"),
        c = c("Amazonas", "Áncash", "Apurímac","Arequipa", "Ayacucho"))

if I place the cursor after the c in "Apurímac" and type an "o", i would get "Apurímaoc" instead of Apurímaco.

I've seen this happen in lines with Spanish accents (e.g. á, é...) and only after the accented characters. Surprisingly, it doesn't seem to happen after capitalized accented characters, like Á in "Áncash". I've tried changing the font in RStudio settings as stated here, here and here with no luck. I suspect it might be related to copying from the clipboard, but I'm not pretty sure about it. Though code runs fine, it's quite annoying.

I'm running RStudio 1.4.1103 on macOS 11.4.

Gonzalo T F
  • 111
  • 10

1 Answers1

0

This occurs because RStudio's editor is not able to properly position the cursor in unicode text using joining marks. The example in your case is , which is made up of the code points:

LATIN SMALL LETTER I
COMBINING ACUTE ACCENT

See https://apps.timwhitlock.info/unicode/inspect?s=i%CC%81 for more details.

Compare this to the NFC normalization of that same character, í, which looks the same but is made up of a single code point:

LATIN SMALL LETTER I WITH ACUTE

See https://apps.timwhitlock.info/unicode/inspect?s=%C3%AD for more details.

Unfortunately, until this is resolved, the best solution is to use the NFC-normalized version of this character; that is, LATIN SMALL LETTER I WITH ACUTE. Or, alternatively, use a unicode escape (e.g. "\u00ed") in place that character.

See also: https://github.com/rstudio/rstudio/issues/8859

Kevin Ushey
  • 20,530
  • 5
  • 56
  • 88