// if we are searching in a selection then create a custom position
// (based on the current selection) and range (based on the originally
// saved selection range)
Position position = null;
Range range = null;
if (display_.getInSelection().getValue() && (targetSelection_ != null))
{
range = targetSelection_.getRange();
if (findType == FindType.Forward)
{
Position selectionEnd = editor_.getSelectionEnd();
if (selectionEnd.isBefore(range.getEnd()))
position = selectionEnd;
}
else
{
Position selectionStart = editor_.getSelectionStart();
if (selectionStart.isAfter(range.getStart()))
position = selectionStart;
}
}
// if this is an incremental search and we don't have a previous
// incremental start position then set it, otherwise clear it
if (incremental)
{
if (incrementalSearchPosition_ == null)
{
if (position != null)
incrementalSearchPosition_ = position;
else
incrementalSearchPosition_ = defaultForward_ ?
editor_.getSelectionStart() :
editor_.getSelectionEnd();
}
// incremental searches always continue searching from the
// original search position
position = incrementalSearchPosition_;
}
else
{
incrementalSearchPosition_ = null;
}
// do the search
Search search = Search.create(searchString,
findType != FindType.Forward,
wrap,
!ignoreCase,
wholeWord,
position,
range,
regex);
try
{
Range resultRange = search.find(editor_.getSession());
if (resultRange == null)
{
if (!incremental)
{
globalDisplay_.showMessage(GlobalDisplay.MSG_INFO,