RSyntaxTextArea icon indicating copy to clipboard operation
RSyntaxTextArea copied to clipboard

Continues search

Open dzmipt opened this issue 1 year ago • 1 comments

Status quo I have a RSTA and search panel with a "what" text and "Find" button. I can type in a "what" text and click "Find" button. "Find" button performs SearchEngine.find(rsta, searchContext). When I click the button multiple time, the next "what" word is selected. This scenario works perfectly.

Describe the solution you'd like I want to modify searching - when I am typing "what" word, I want the search is being performed in the background.

For example, if I have rsta with the following content abc abd The caret is at offset 0.

  1. I type a => the first char "a" is selected.
  2. I press b; "what" is ab => the first 2 chars "ab" are selected.
  3. I press d; "what" is now abd => and only now "abd" is selected.

What I did I added whatTextField.getDocument().addDocumentListener() with calling SearchEngine.find(). However in the use-case above when I pressed on the 2nd step b, the second occurrence of "ab" is selected.

What is proposed I think it is needed one more field to the SearchContext which controls if the search should start from the selectionStart or from the selectionEnd. And also SearchContext.forward should be taken into account.

dzmipt avatar Jan 19 '24 18:01 dzmipt