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

Marked Count is always zero if cursor at end of file #555

Closed SamKry closed 4 months ago

SamKry commented 5 months ago

Description There is a bug when using SearchEngine.find(...) . The problem is, thata new SearchResult() is returned if there is no text after the cursot (Caret). This leads to a wrong SearchResult, because the markedCount is then set to 0 even if there are multiple markings before the cursor.

Steps to Reproduce Specific steps to reproduce the behavior:

  1. Set the cursor at the end of a JTextArea
  2. call the find method using a valid SearchContext (e.g. search for "e" in a text that contains some "e")
  3. Now all the "e" got marked but an empty new SearchResult is returned (variable markedCount is set to 0)
  4. If you set the cursor one back (second last position), everything works as expected

Expected behavior The variable markedCount should be set to the correct number when returned.

Actual behavior variable markedCount is set to 0 even if there are markings.

Screenshots Add a screenshot if it helps explain the problem.

Java version jdk-17.0.6.10

Additional context Just change the line to return new SearchResult(null, 0, markAllCount); in the SearchEngine Class

bobbylight commented 4 months ago

Thanks for the fix!