Disable wrapped FindNext

SyntaxEditor for WPF Forum

Posted 13 years ago by Martin - Blaise - Statistics Netherlands
Avatar
I want to search multiple documents. I want to use
result = this.ActiveView.Searcher.FindNext(options);
to search each document. However, after the last found item (if any) in a document, i don't want the search to be wrapped to the top of this same document. Is there a possibilty to prevent this feature by setting a flag (FlagManager) or so?

Usage of the sanpshot FindNext seems to make things complicated, so that i want to avoid.

I hope my question is clear:)

Greetz Martin

Comments (3)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Martin,

From the code you posted, you are using the UI search model, which will wrap. You'd want to instead use the document search model, which is lower-level and is what the UI search model calls. That is the snapshot's FindNext method and/or related methods.

You pass ITextSnapshot.FindNext options (you can pass the same instance you pass the UI search model), the start offset, and whether the search can wrap (false in your case). So it's pretty easy to use.


Actipro Software Support

Posted 13 years ago by Martin - Blaise - Statistics Netherlands
Avatar
Looks ok, but correct me if i am wrong: it doesn't show in the syntaxeditor view. So i have to apply an adorner somehow to mark the text and move the caret? Or is there some function for that?

(Don't want to redo what you already made:))

Now i just select the found or replaced text, but then searching Selected text won't work anymore;)

[Modified at 01/12/2011 08:52 AM]
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Martin,

The ISearchResultSet that comes back will contain a single result from FindNext if something was found. That ISearchResult has a FindSnapshotRange property. So you can call editor.ActiveView.Selection.SelectRange(result.FindSnapshotRange.TextRange) to select that range. But if you are allowing search in selection then that won't work.

An alternative to all this is to do a double search but that will take longer. For instance, use the document search model to first search without wrapping to see if a match was found. Then if so call the UI search model to search again and handle the selection update.


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.