MCPcopy Create free account
hub / github.com/SpartanJ/eepp / findNextText

Method findNextText

src/tools/ecode/docsearchcontroller.cpp:285–343  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283}
284
285void DocSearchController::findNextText( SearchState& search, bool resetSelection ) {
286 if ( search.text.empty() )
287 search.text = mLastSearch;
288 if ( !search.editor || !mSplitter->editorExists( search.editor ) || search.text.empty() )
289 return;
290
291 search.editor->getDocument().setActiveClient( search.editor );
292 mLastSearch = search.text;
293
294 Uint64 tag = String::hash( "DocSearchController::findNextText-" +
295 search.editor->getDocument().getHashHexString() );
296
297 mApp->getThreadPool()->removeWithTag( tag );
298 mApp->getThreadPool()->run(
299 [this, search, resetSelection] {
300 ScopedOp op( [this] { mSearchingCount++; }, [this] { mSearchingCount--; } );
301 TextDocument& doc = search.editor->getDocument();
302 TextRange range = doc.getDocRange();
303 TextPosition from =
304 resetSelection ? TextPosition( 0, 0 ) : doc.getSelection( true ).end();
305
306 if ( search.range.isValid() ) {
307 range = doc.sanitizeRange( search.range ).normalized();
308 from = from < range.start() ? range.start() : from;
309 }
310
311 String txt( search.text );
312 if ( search.escapeSequences )
313 txt.unescape();
314
315 TextRange found =
316 doc.find( txt, from, search.caseSensitive, search.wholeWord, search.type, range )
317 .result;
318
319 if ( found.isValid() ) {
320 doc.setSelection( found.reversed() );
321 mFindInput->runOnMainThread( [this, search] {
322 mSplitter->addEditorPositionToNavigationHistory( search.editor );
323 mFindInput->removeClass( "error" );
324 } );
325 return;
326 } else {
327 found = doc.find( txt, range.start(), search.caseSensitive, search.wholeWord,
328 search.type, range )
329 .result;
330 if ( found.isValid() ) {
331 doc.setSelection( found.reversed() );
332 mFindInput->runOnMainThread( [this, search] {
333 mSplitter->addEditorPositionToNavigationHistory( search.editor );
334 mFindInput->removeClass( "error" );
335 } );
336 return;
337 }
338 }
339
340 mFindInput->runOnMainThread( [this] { mFindInput->addClass( "error" ); } );
341 },
342 {}, tag );

Callers 1

onCodeEditorCreatedMethod · 0.45

Calls 15

hashFunction · 0.85
TextPositionFunction · 0.85
setActiveClientMethod · 0.80
getDocumentMethod · 0.80
getHashHexStringMethod · 0.80
removeWithTagMethod · 0.80
getDocRangeMethod · 0.80
normalizedMethod · 0.80
sanitizeRangeMethod · 0.80
runOnMainThreadMethod · 0.80
removeClassMethod · 0.80

Tested by

no test coverage detected