@@ -110,12 +110,23 @@ void CodeFragmentManager::Private::FragmentInfo::findBlockMarkers()
110
110
{
111
111
// printf("gotoLine(pos=%p,start=%d,target=%d) backward\n",(void*)startPos,startLine,targetLine);
112
112
while (startLine>=targetLine && startPos>=startBuf && (cc=*startPos--)) { if (cc==' \n ' ) startLine--; }
113
- startPos++;
113
+ if (startPos>startBuf)
114
+ {
115
+ // given fragment:
116
+ // line1\n
117
+ // line2\n
118
+ // line3
119
+ // and targetLine==2 then startPos ends at character '1' of line 1 before we detect that startLine<targetLine,
120
+ // so we need to advance startPos with 2 to be at the start of line2, unless we are already at the first line.
121
+ startPos+=2 ;
122
+ }
123
+ // printf("result=[%s]\n",qPrint(QCString(startPos).left(20)));
114
124
}
115
125
else
116
126
{
117
127
// printf("gotoLine(pos=%p,start=%d,target=%d) forward\n",(void*)startPos,startLine,targetLine);
118
128
while (startLine<targetLine && (cc=*startPos++)) { if (cc==' \n ' ) startLine++; }
129
+ // printf("result=[%s]\n",qPrint(QCString(startPos).left(20)));
119
130
}
120
131
return startPos;
121
132
};
@@ -366,13 +377,13 @@ void CodeFragmentManager::parseCodeFragment(OutputCodeList & codeOutList,
366
377
}
367
378
}
368
379
// use the recorded OutputCodeList from the cache to output a pre-recorded fragment
369
- auto blockKv = codeFragment->blocksById .find (blockId.str ());
370
- if (blockKv!= codeFragment->blocksById .end ())
380
+ auto blockKv = codeFragment->blocksById .find (blockId.str ());
381
+ if (blockKv != codeFragment->blocksById .end ())
371
382
{
372
383
const auto &marker = blockKv->second ;
373
384
int startLine = marker->lines [0 ];
374
385
int endLine = marker->lines [1 ];
375
- AUTO_TRACE_ADD (" replay(start={},end={})" ,startLine,endLine);
386
+ AUTO_TRACE_ADD (" replay(start={},end={}) fileContentsTrimLeft.empty()={} " ,startLine,endLine,codeFragment-> fileContentsTrimLeft . isEmpty () );
376
387
if (!trimLeft || codeFragment->fileContentsTrimLeft .isEmpty ()) // replay the normal version
377
388
{
378
389
codeFragment->recorderCodeList .get <OutputCodeRecorder>()->replay (codeOutList,startLine+1 ,endLine,showLineNumbers);
0 commit comments