fix: handle empty lines in codeframe
This commit is contained in:
		
							parent
							
								
									7f6abda6dd
								
							
						
					
					
						commit
						4b2610c468
					
				| @ -20,7 +20,10 @@ export function generateCodeFrame( | |||||||
|         if (j === i) { |         if (j === i) { | ||||||
|           // push underline
 |           // push underline
 | ||||||
|           const pad = start - (count - lineLength) + 1 |           const pad = start - (count - lineLength) + 1 | ||||||
|           const length = end > count ? lineLength - pad : end - start |           const length = Math.max( | ||||||
|  |             0, | ||||||
|  |             end > count ? lineLength - pad : end - start | ||||||
|  |           ) | ||||||
|           res.push(`   |  ` + ' '.repeat(pad) + '^'.repeat(length)) |           res.push(`   |  ` + ' '.repeat(pad) + '^'.repeat(length)) | ||||||
|         } else if (j > i) { |         } else if (j > i) { | ||||||
|           if (end > count) { |           if (end > count) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user