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

Method invalidateCache

src/eepp/ui/doc/documentview.cpp:94–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92}
93
94void DocumentView::invalidateCache() {
95 if ( 0 == mMaxWidth || !mDoc )
96 return;
97
98 if ( mDoc->isLoading() ) {
99 mPendingReconstruction = !isOneToOne();
100 return;
101 }
102
103 Clock clock;
104 BoolScopedOp op( mUnderConstruction, true );
105
106 mVisibleLines.clear();
107 mDocLineToVisibleIndex.clear();
108 mVisibleLinesOffset.clear();
109
110 bool wrap = mConfig.mode != LineWrapMode::NoWrap;
111 Int64 linesCount = mDoc->linesCount();
112 mVisibleLines.reserve( linesCount );
113 mVisibleLinesOffset.reserve( linesCount );
114 mDocLineToVisibleIndex.reserve( linesCount );
115
116 for ( auto i = 0; i < linesCount; i++ ) {
117 if ( isFolded( i, true ) ) {
118 mVisibleLinesOffset.emplace_back(
119 wrap ? LineWrap::computeOffsets(
120 mDoc->line( i ).getText().view(), mFontStyle, mConfig.tabWidth,
121 eemax( mMaxWidth - mWhiteSpaceWidth, mWhiteSpaceWidth ) )
122 : 0 );
123 mDocLineToVisibleIndex.push_back( static_cast<Int64>( VisibleIndex::invalid ) );
124 } else {
125 auto lb = wrap ? computeLineBreaks( *mDoc, i, mFontStyle, mMaxWidth, mConfig.mode,
126 mConfig.keepIndentation, mConfig.tabWidth,
127 mWhiteSpaceWidth, mConfig.tabStops )
128 : LineWrapInfo{ { 0 }, 0.f };
129 mVisibleLinesOffset.emplace_back( lb.paddingStart );
130 bool first = true;
131 for ( const auto& col : lb.wraps ) {
132 mVisibleLines.emplace_back( i, col );
133 if ( first ) {
134 mDocLineToVisibleIndex.emplace_back( mVisibleLines.size() - 1 );
135 first = false;
136 }
137 }
138 }
139 }
140
141 eeASSERT( static_cast<Int64>( mDocLineToVisibleIndex.size() ) == linesCount );
142
143 mPendingReconstruction = false;
144
145 onVisibleLinesCountChange();
146
147 Log::debug( "DocumentView for \"%s\" generated in %s", mDoc->getFilePath(),
148 clock.getElapsedTime().toString() );
149}
150
151VisibleIndex DocumentView::toVisibleIndex( Int64 docIdx, bool retLast ) const {

Callers

nothing calls this directly

Calls 13

eemaxFunction · 0.85
debugFunction · 0.85
linesCountMethod · 0.80
reserveMethod · 0.80
viewMethod · 0.80
push_backMethod · 0.80
getFilePathMethod · 0.80
getElapsedTimeMethod · 0.80
isLoadingMethod · 0.45
clearMethod · 0.45
getTextMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected