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

Method updateHighlightWordCache

src/eepp/ui/uicodeeditor.cpp:3792–3840  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3790}
3791
3792void UICodeEditor::updateHighlightWordCache() {
3793 if ( mHighlightWord.isEmpty() )
3794 return;
3795
3796 if ( getUISceneNode()->hasThreadPool() ) {
3797 Uint64 tag = reinterpret_cast<Uint64>( this );
3798 removeActionsByTag( tag );
3799 runOnMainThread(
3800 [this, tag]() {
3801 getUISceneNode()->getThreadPool()->removeWithTag( tag );
3802 getUISceneNode()->getThreadPool()->run(
3803 [this]() {
3804 if ( mDoc->isRunningTransaction() )
3805 return;
3806 Clock docSearch;
3807 mHighlightWordProcessing++;
3808 mDoc->stopActiveFindAll();
3809
3810 auto wordCache = mDoc->findAll(
3811 mHighlightWord.escapeSequences ? String::unescape( mHighlightWord.text )
3812 : mHighlightWord.text,
3813 mHighlightWord.caseSensitive, mHighlightWord.wholeWord,
3814 mHighlightWord.type, mHighlightWord.range );
3815
3816 {
3817 Lock l( mHighlightWordCacheMutex );
3818 mHighlightWordCache = wordCache.ranges();
3819 }
3820
3821 Log::info( "Document search triggered in document: \"%s\", searched for "
3822 "\"%s\" and took %.2f ms",
3823 mDoc->getFilename().c_str(),
3824 mHighlightWord.text.toUtf8().c_str(),
3825 docSearch.getElapsedTime().asMilliseconds() );
3826 },
3827 [this]( const auto& ) { mHighlightWordProcessing--; }, tag );
3828 },
3829 Milliseconds( 16 ), tag );
3830 } else {
3831 if ( mDoc->isRunningTransaction() )
3832 return;
3833 mHighlightWordCache =
3834 mDoc->findAll( mHighlightWord.escapeSequences ? String::unescape( mHighlightWord.text )
3835 : mHighlightWord.text,
3836 mHighlightWord.caseSensitive, mHighlightWord.wholeWord,
3837 mHighlightWord.type, mHighlightWord.range, 100 )
3838 .ranges();
3839 }
3840}
3841
3842void UICodeEditor::setHighlightWord( const TextSearchParams& highlightWord ) {
3843 if ( mHighlightWord != highlightWord ) {

Callers

nothing calls this directly

Calls 15

infoFunction · 0.85
MillisecondsFunction · 0.85
hasThreadPoolMethod · 0.80
removeWithTagMethod · 0.80
isRunningTransactionMethod · 0.80
stopActiveFindAllMethod · 0.80
findAllMethod · 0.80
rangesMethod · 0.80
c_strMethod · 0.80
getFilenameMethod · 0.80
toUtf8Method · 0.80
asMillisecondsMethod · 0.80

Tested by

no test coverage detected