mirror of
				https://github.com/sharkdp/bat.git
				synced 2025-10-31 15:12:12 +00:00 
			
		
		
		
	Don't add artificial newline to last line if --style=plain
This fixes #1438. Note however, that using a pager such as less will add a newline itself. So to actually not print a newline for such files, you need to either disable paging: bat --style=plain --paging=never no-newline-at-end-of-file.txt or use a "pager" that does not add a newline: bat --style=plain --pager=cat no-newline-at-end-of-file.txt Note that we also update syntax tests file since a bunch of them had missing newlines on the last lines.
This commit is contained in:
		| @@ -5,6 +5,8 @@ | |||||||
|  |  | ||||||
| ## Bugfixes | ## Bugfixes | ||||||
|  |  | ||||||
|  | - If the last line doesn't end with a newline character, don't add it if `--style=plain`, see #1438 (@Enselic) | ||||||
|  |  | ||||||
| ## Other | ## Other | ||||||
|  |  | ||||||
| ## Syntaxes | ## Syntaxes | ||||||
|   | |||||||
| @@ -460,7 +460,7 @@ impl<'a> Printer for InteractivePrinter<'a> { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if line.bytes().next_back() != Some(b'\n') { |             if !self.config.style_components.plain() && line.bytes().next_back() != Some(b'\n') { | ||||||
|                 writeln!(handle)?; |                 writeln!(handle)?; | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|   | |||||||
| @@ -175,4 +175,4 @@ | |||||||
| [38;2;117;113;94m\u{ad}[0m[38;2;249;38;114m␊[0m | [38;2;117;113;94m\u{ad}[0m[38;2;249;38;114m␊[0m | ||||||
| [38;2;117;113;94m\u{ae}[0m[38;2;249;38;114m␊[0m | [38;2;117;113;94m\u{ae}[0m[38;2;249;38;114m␊[0m | ||||||
| [38;2;249;38;114m␊[0m | [38;2;249;38;114m␊[0m | ||||||
| [38;2;248;248;242mHere's[0m[38;2;102;217;239m·[0m[38;2;248;248;242ma[0m[38;2;102;217;239m·[0m[38;2;248;248;242mline[0m[38;2;102;217;239m·[0m[38;2;248;248;242mwith[0m[38;2;102;217;239m·[0m[38;2;248;248;242mmultiple[0m[38;2;102;217;239m·[0m[38;2;248;248;242mcharacters.[0m | [38;2;248;248;242mHere's[0m[38;2;102;217;239m·[0m[38;2;248;248;242ma[0m[38;2;102;217;239m·[0m[38;2;248;248;242mline[0m[38;2;102;217;239m·[0m[38;2;248;248;242mwith[0m[38;2;102;217;239m·[0m[38;2;248;248;242mmultiple[0m[38;2;102;217;239m·[0m[38;2;248;248;242mcharacters.[0m[38;2;249;38;114m␊[0m | ||||||
|   | |||||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
		Reference in New Issue
	
	Block a user