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

Method findPrevText

src/tools/ecode/docsearchcontroller.cpp:232–283  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232void DocSearchController::findPrevText( SearchState& search ) {
233 if ( search.text.empty() )
234 search.text = mLastSearch;
235 if ( !search.editor || !mSplitter->editorExists( search.editor ) || search.text.empty() )
236 return;
237
238 search.editor->getDocument().setActiveClient( search.editor );
239 mLastSearch = search.text;
240
241 Uint64 tag = String::hash( "DocSearchController::findPrevText-" +
242 search.editor->getDocument().getHashHexString() );
243 mApp->getThreadPool()->removeWithTag( tag );
244 mApp->getThreadPool()->run( [this, search] {
245 ScopedOp op( [this] { mSearchingCount++; }, [this] { mSearchingCount--; } );
246 TextDocument& doc = search.editor->getDocument();
247 TextRange range = doc.getDocRange();
248 TextPosition from = doc.getSelection( true ).start();
249 if ( search.range.isValid() ) {
250 range = doc.sanitizeRange( search.range ).normalized();
251 from = from < range.start() ? range.start() : from;
252 }
253
254 String txt( search.text );
255 if ( search.escapeSequences )
256 txt.unescape();
257
258 TextRange found = doc.findLast( txt, from, search.caseSensitive, search.wholeWord,
259 search.type, search.range )
260 .result;
261 if ( found.isValid() ) {
262 doc.setSelection( found );
263 mFindInput->runOnMainThread( [this, search] {
264 mSplitter->addEditorPositionToNavigationHistory( search.editor );
265 mFindInput->removeClass( "error" );
266 } );
267 return;
268 } else {
269 found = doc.findLast( txt, range.end(), search.caseSensitive, search.wholeWord,
270 search.type, range )
271 .result;
272 if ( found.isValid() ) {
273 doc.setSelection( found );
274 mFindInput->runOnMainThread( [this, search] {
275 mSplitter->addEditorPositionToNavigationHistory( search.editor );
276 mFindInput->removeClass( "error" );
277 } );
278 return;
279 }
280 }
281 mFindInput->runOnMainThread( [this] { mFindInput->addClass( "error" ); } );
282 } );
283}
284
285void DocSearchController::findNextText( SearchState& search, bool resetSelection ) {
286 if ( search.text.empty() )

Callers 1

onCodeEditorCreatedMethod · 0.45

Calls 15

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

Tested by

no test coverage detected