mirror of
				https://github.com/spectreconsole/spectre.console.git
				synced 2025-10-25 15:19:23 +00:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 22d4af4482 | 
| @@ -18,6 +18,7 @@ namespace Spectre.Console.Tests | |||||||
|         public Color Background { get; set; } |         public Color Background { get; set; } | ||||||
|  |  | ||||||
|         public StringWriter Writer { get; } |         public StringWriter Writer { get; } | ||||||
|  |         public string RawOutput => Writer.ToString(); | ||||||
|         public string Output => Writer.ToString().TrimEnd('\n'); |         public string Output => Writer.ToString().TrimEnd('\n'); | ||||||
|         public IReadOnlyList<string> Lines => Output.Split(new char[] { '\n' }); |         public IReadOnlyList<string> Lines => Output.Split(new char[] { '\n' }); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -21,6 +21,20 @@ namespace Spectre.Console.Tests.Unit | |||||||
|                 .ShouldBe("Hello World"); |                 .ShouldBe("Hello World"); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         [Fact] | ||||||
|  |         public void Should_Write_Line_Breaks() | ||||||
|  |         { | ||||||
|  |             // Given | ||||||
|  |             var fixture = new PlainConsole(width: 5); | ||||||
|  |             var text = Text.New("\n\n"); | ||||||
|  |  | ||||||
|  |             // When | ||||||
|  |             fixture.Render(text); | ||||||
|  |  | ||||||
|  |             // Then | ||||||
|  |             fixture.RawOutput.ShouldBe("\n\n"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         [Fact] |         [Fact] | ||||||
|         public void Should_Split_Unstyled_Text_To_New_Lines_If_Width_Exceeds_Console_Width() |         public void Should_Split_Unstyled_Text_To_New_Lines_If_Width_Exceeds_Console_Width() | ||||||
|         { |         { | ||||||
|   | |||||||
| @@ -136,7 +136,7 @@ namespace Spectre.Console | |||||||
|         /// <inheritdoc/> |         /// <inheritdoc/> | ||||||
|         IEnumerable<Segment> IRenderable.Render(RenderContext context, int width) |         IEnumerable<Segment> IRenderable.Render(RenderContext context, int width) | ||||||
|         { |         { | ||||||
|             if (string.IsNullOrWhiteSpace(_text)) |             if (string.IsNullOrEmpty(_text)) | ||||||
|             { |             { | ||||||
|                 return Array.Empty<Segment>(); |                 return Array.Empty<Segment>(); | ||||||
|             } |             } | ||||||
| @@ -192,7 +192,7 @@ namespace Spectre.Console | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 if (!last) |                 if (!last || line.Count == 0) | ||||||
|                 { |                 { | ||||||
|                     result.Add(Segment.LineBreak()); |                     result.Add(Segment.LineBreak()); | ||||||
|                 } |                 } | ||||||
| @@ -214,7 +214,10 @@ namespace Spectre.Console | |||||||
|                 var index = segment.Text.IndexOf("\n", StringComparison.OrdinalIgnoreCase); |                 var index = segment.Text.IndexOf("\n", StringComparison.OrdinalIgnoreCase); | ||||||
|                 if (index == -1) |                 if (index == -1) | ||||||
|                 { |                 { | ||||||
|                     result.Add(segment); |                     if (!string.IsNullOrEmpty(segment.Text)) | ||||||
|  |                     { | ||||||
|  |                         result.Add(segment); | ||||||
|  |                     } | ||||||
|                 } |                 } | ||||||
|                 else |                 else | ||||||
|                 { |                 { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user