[QScintilla] Resetting search for replace

Phil Thompson phil at riverbankcomputing.com
Sat Nov 17 11:31:37 GMT 2018


On 16 Nov 2018, at 8:31 pm, Manuel Gómez <mgrojo at gmail.com> wrote:
> 
> Hi,
> 
> How should a search be canceled so a subsequent call to replace does nothing?

Call findFirst() with an empty search string.

> The following sequence would insert the searched text instead of actually replacing or doing nothing:
> 
> // user presses my find button
> findFirst(...);
> 
> // user closes the find dialog
> clearSelection();
> 
> // user opens again the find/replace dialog and clicks Replace
> replace();
> 
> If I do this, the behaviour improves:
> 
> // user opens again the find/replace dialog and clicks replace
> if (hasSelectedText())
>    replace();
> 
> But if the user makes any selection before opening the dialog, the incorrect text is replaced, not fulfilling the searched term. Any better solution?

I could add a cancelFind() which does the same as findFirst('').

Phil


More information about the QScintilla mailing list