| 3790 | } |
| 3791 | |
| 3792 | void 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 | |
| 3842 | void UICodeEditor::setHighlightWord( const TextSearchParams& highlightWord ) { |
| 3843 | if ( mHighlightWord != highlightWord ) { |
nothing calls this directly
no test coverage detected