bobbylight / RSyntaxTextArea

A syntax highlighting, code folding text editor for Java Swing applications.
BSD 3-Clause "New" or "Revised" License
1.12k stars 259 forks source link

Slow performance when selecting a very long word #487

Open ptorngren opened 1 year ago

ptorngren commented 1 year ago

Description Navigating into a very long (70k) selected string using the mouse causes the editor to freeze for a long time. This happens also when word-wrap is not enabled and is hence not an exact duplicate of issue 41

Steps to Reproduce Specific steps to reproduce the behavior:

  1. Start the demo app
  2. Copy the contents of the attached file sakila-insert.txt and paste it into the editor area of the demo app
  3. Double-click to select the long hex string on line 6 : 'X'89504e470d0a1a0a0000 ....
  4. Use the mouse to click somewhere near the end of the string

Expected behavior The string is deselected and the cursor is immediately placed where I clicked.

Actual behavior The editor freezes for several seconds (approx 15 secs on a Mac M1 Pro) before eventually placing the cursor in the expected location.

Screenshots image

Java version Java 8 (Azul Zulu 1.8_322) Java 11 (Eclipse Temurin 11.0.14)

Additional context The problem seems to be in the method TokenImpl.getListOffset() (the loop at line 476 - 492)