mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-10-31 07:04:04 +00:00 
			
		
		
		
	Skip syntax highlighting for long lines (#2165)
* Skip highlighting for long lines * Run cargo fmt, update changelog
This commit is contained in:
		| @@ -12,6 +12,7 @@ | ||||
| ## Other | ||||
|  | ||||
| - Include info about custom assets in `--diagnostics` if used. See #2107, #2144 (@Enselic) | ||||
| - Skip syntax highlighting on long lines (> 16384 chars) to help improve performance. See #2165 (@keith-hall) | ||||
|  | ||||
| ## Syntaxes | ||||
|  | ||||
|   | ||||
| @@ -445,9 +445,18 @@ impl<'a> Printer for InteractivePrinter<'a> { | ||||
|                     return Ok(()); | ||||
|                 } | ||||
|             }; | ||||
|             // skip syntax highlighting on long lines | ||||
|             if line.len() > 1024 * 16 { | ||||
|                 let mut empty = highlighter_from_set | ||||
|                     .highlighter | ||||
|                     .highlight(&"\n", highlighter_from_set.syntax_set); | ||||
|                 empty[0].1 = line.as_ref(); | ||||
|                 empty | ||||
|             } else { | ||||
|                 highlighter_from_set | ||||
|                     .highlighter | ||||
|                     .highlight(&line, highlighter_from_set.syntax_set) | ||||
|             } | ||||
|         }; | ||||
|  | ||||
|         if out_of_range { | ||||
|   | ||||
							
								
								
									
										3
									
								
								tests/examples/longline.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tests/examples/longline.json
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Reference in New Issue
	
	Block a user