| 2341 | } |
| 2342 | |
| 2343 | void UICodeEditor::onDocumentLineMove( const Int64& fromLine, const Int64& toLine, |
| 2344 | const Int64& numLines ) { |
| 2345 | mDocView.updateCache( fromLine, toLine, numLines ); |
| 2346 | |
| 2347 | if ( !mColorBoxesCache.empty() ) { |
| 2348 | Int64 linesCount = mDoc->linesCount(); |
| 2349 | if ( numLines > 0 ) { |
| 2350 | for ( Int64 i = linesCount - 1; i >= fromLine; --i ) { |
| 2351 | auto lineIt = mColorBoxesCache.find( i - numLines ); |
| 2352 | if ( lineIt != mColorBoxesCache.end() ) { |
| 2353 | const auto& line = lineIt->second; |
| 2354 | if ( line.first == mDoc->getLineHash( i ) ) { |
| 2355 | auto nl = mColorBoxesCache.extract( lineIt ); |
| 2356 | nl.key() = i; |
| 2357 | mColorBoxesCache.insert( std::move( nl ) ); |
| 2358 | } |
| 2359 | } |
| 2360 | } |
| 2361 | } else if ( numLines < 0 ) { |
| 2362 | for ( Int64 i = fromLine; i < linesCount; i++ ) { |
| 2363 | auto lineIt = mColorBoxesCache.find( i - numLines ); |
| 2364 | if ( lineIt != mColorBoxesCache.end() && |
| 2365 | lineIt->second.first == mDoc->getLineHash( i ) ) { |
| 2366 | auto nl = mColorBoxesCache.extract( lineIt ); |
| 2367 | nl.key() = i; |
| 2368 | mColorBoxesCache[i] = std::move( nl.mapped() ); |
| 2369 | } |
| 2370 | } |
| 2371 | } |
| 2372 | } |
| 2373 | |
| 2374 | if ( !mFont || mFont->isMonospace() || mLinesWidthCache.empty() ) |
| 2375 | return; |
| 2376 | |
| 2377 | Int64 linesCount = mDoc->linesCount(); |
| 2378 | if ( numLines > 0 ) { |
| 2379 | for ( Int64 i = linesCount - 1; i >= fromLine; --i ) { |
| 2380 | auto lineIt = mLinesWidthCache.find( i - numLines ); |
| 2381 | if ( lineIt != mLinesWidthCache.end() ) { |
| 2382 | const auto& line = lineIt->second; |
| 2383 | if ( line.first == mDoc->getLineHash( i ) ) { |
| 2384 | auto nl = mLinesWidthCache.extract( lineIt ); |
| 2385 | nl.key() = i; |
| 2386 | mLinesWidthCache.insert( std::move( nl ) ); |
| 2387 | } |
| 2388 | } |
| 2389 | } |
| 2390 | } else if ( numLines < 0 ) { |
| 2391 | for ( Int64 i = fromLine; i < linesCount; i++ ) { |
| 2392 | auto lineIt = mLinesWidthCache.find( i - numLines ); |
| 2393 | if ( lineIt != mLinesWidthCache.end() && |
| 2394 | lineIt->second.first == mDoc->getLineHash( i ) ) { |
| 2395 | auto nl = mLinesWidthCache.extract( lineIt ); |
| 2396 | nl.key() = i; |
| 2397 | mLinesWidthCache[i] = std::move( nl.mapped() ); |
| 2398 | } |
| 2399 | } |
| 2400 | } |
no test coverage detected