Skip to content

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

@SamKry

Description

@SamKry

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions