Show blank source lines as blank
highlightSource returns a 'No preview available' placeholder for empty input, so every empty line in the source viewer showed that text.
This commit is contained in:
+1
-1
@@ -309,7 +309,7 @@ function mountSourceViewer(file){
|
||||
frame=0;const version=++drawVersion,start=Math.max(0,Math.floor(viewer.scrollTop/lineHeight)-12),count=Math.ceil(viewer.clientHeight/lineHeight)+24,chunkStart=Math.floor(start/600)*600;
|
||||
const lines=await loadSourceChunk(file,chunkStart,600);if(version!==drawVersion||!viewer.isConnected)return;
|
||||
const offset=start-chunkStart,end=Math.min(lines.length,offset+count);windowElement.style.transform=`translateY(${start*lineHeight}px)`;
|
||||
windowElement.innerHTML=lines.slice(offset,end).map((line,index)=>`<span class="source-line" data-line="${start+index+1}">${highlightSource(line,file)||' '}</span>`).join('');
|
||||
windowElement.innerHTML=lines.slice(offset,end).map((line,index)=>`<span class="source-line" data-line="${start+index+1}">${line?highlightSource(line,file):' '}</span>`).join('');
|
||||
};
|
||||
viewer.addEventListener('scroll',()=>{if(!frame)frame=requestAnimationFrame(draw);},{passive:true});draw();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user