antonWetzel / typst-languagetool

LanguageTool Integration for Typst for spell and grammer check
MIT License
36 stars 9 forks source link

Panick at src\convert.rs:20:32: when using #emoji #20

Closed Eismandel closed 3 months ago

Eismandel commented 3 months ago

Dear Anton,

I'm using typst-languagetool to check my touying presentation. At this line I get an panic in src\convert.rs:20:32:

emoji.face

thread 'main' panicked at src\convert.rs:20:32:
range end index 291 out of range for slice of length 290
stack backtrace:
   0:     0x7ff66d9d4b8a - <unknown>
   1:     0x7ff66d9f26fb - <unknown>
   2:     0x7ff66d9d0531 - <unknown>
   3:     0x7ff66d9d4976 - <unknown>
   4:     0x7ff66d9d6b1f - <unknown>
   5:     0x7ff66d9d67b7 - <unknown>
   6:     0x7ff66d9d705d - <unknown>
   7:     0x7ff66d9d6f19 - <unknown>
   8:     0x7ff66d9d5219 - <unknown>
   9:     0x7ff66d9d6bd6 - <unknown>
  10:     0x7ff66da31917 - <unknown>
  11:     0x7ff66d9f4b74 - <unknown>
  12:     0x7ff66da31e39 - <unknown>
  13:     0x7ff66cbfcc88 - <unknown>
  14:     0x7ff66cbfec52 - <unknown>
  15:     0x7ff66cbfc8a3 - <unknown>
  16:     0x7ff66cba4e92 - <unknown>
  17:     0x7ff66cb9ea1b - <unknown>
  18:     0x7ff66cbb4b44 - <unknown>
  19:     0x7ff66cbc52bf - <unknown>
  20:     0x7ff66cb978c6 - <unknown>
  21:     0x7ff66cb7a71a - <unknown>
  22:     0x7ff66d9ca6c2 - <unknown>
  23:     0x7ff66cbc544c - <unknown>
  24:     0x7ff66d9fa630 - <unknown>
  25:     0x7ffa65bc257d - BaseThreadInitThunk
  26:     0x7ffa6786af28 - RtlUserThreadStart

Without the emoji function everything runs well.

What am I doing wrong?

Best regards

antonWetzel commented 3 months ago

The conversion counted UTF-8-clusters, but java uses UTF-16 chars. The emoji is 1 UTF-8-cluster, but 2 UTF-16 chars, therefore the crash.

With 3f8e02f2be8011da56846b1326de1502fbbc734e the conversion uses UTF-16, so this should not crash anymore. If the issue still persists, please reopen the issue.