Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console.WriteLine occasionally doesn't break the line #15455

Closed
Rand-Random opened this issue May 26, 2023 · 7 comments
Closed

Console.WriteLine occasionally doesn't break the line #15455

Rand-Random opened this issue May 26, 2023 · 7 comments
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.

Comments

@Rand-Random
Copy link

Windows Terminal version

1.16.10262.0

Windows build number

10.0.22621.1702

Other Software

No response

Steps to reproduce

I did explain the issue in detail on Stackoverflow
https://stackoverflow.com/questions/76341712

if linking to Stackoverflow isn't sufficient, please let me know.

Expected Behavior

Console.Writeline() should always produce a new line

Actual Behavior

see the stackoverflow post

@Rand-Random Rand-Random added Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels May 26, 2023
@zadjii-msft
Copy link
Member

I've got a crazy hunch. I think this is probably the same thing as #14512.

Can you try installing Terminal Preview, v1.18, setting that as the "Default Terminal Application" in the Settings App, and try again?

@Rand-Random
Copy link
Author

@zadjii-msft
thanks for the fast response

#14512 did partially help, in stackoverflow comment I mentioned this:

@bdcoder - without thread sleep the output disappears completly (only the last view lines remain) but everything above the scrollviewer threshhold is gone: i.stack.imgur.com/U9reA.png

this issue got resolved, but my original problem the line breaks (apparently after resizing the window) is still there
image

image

@Rand-Random Rand-Random changed the title Console.WriteLine occasionaly doesn't break the line Console.WriteLine occasionally doesn't break the line May 26, 2023
@elsaco
Copy link

elsaco commented May 26, 2023

@Rand-Random this issue is triggered when resizing horizontally only, and you have output past BufferWidth. Starting with default terminal size:

bw120

and horizontal resize by one column:

bw121

It's easy to see what happen when using hex:

Before buffer resize:

00000000: 3061 6161 6161 6161 6161 6161 6161 6161  0aaaaaaaaaaaaaaa
00000010: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000020: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000030: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000040: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000050: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000060: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000070: 6161 6161 6161 610a 3161 6161 6161 6161  aaaaaaa.1aaaaaaa
00000080: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000090: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
000000a0: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
000000b0: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
000000c0: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
000000d0: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
000000e0: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
000000f0: 0a32 6161 6161 6161 6161 6161 6161 6161  .2aaaaaaaaaaaaaa
00000100: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000110: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000120: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000130: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000140: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000150: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000160: 6161 6161 6161 6161 6161 0a              aaaaaaaaaa.

and after:

00000000: 3061 6161 6161 6161 6161 6161 6161 6161  0aaaaaaaaaaaaaaa
00000010: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000020: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000030: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000040: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000050: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000060: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000070: 6161 6161 6161 610a 3161 6161 6161 6161  aaaaaaa.1aaaaaaa
00000080: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000090: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
000000a0: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
000000b0: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
000000c0: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
000000d0: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
000000e0: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
000000f0: 3261 6161 6161 6161 6161 6161 6161 6161  2aaaaaaaaaaaaaaa
00000100: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000110: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000120: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000130: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000140: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000150: 6161 6161 6161 6161 6161 6161 6161 6161  aaaaaaaaaaaaaaaa
00000160: 6161 6161 6161 6161 610a                 aaaaaaaaa.


Notice how 0x0A (line feed) is gone between line 1 and 2.

@carlos-zamora
Copy link
Member

carlos-zamora commented May 31, 2023

Thanks for filing this! Gonna mark this as a duplicate of #6901 (comment)

/dup #6901

@microsoft-github-policy-service
Copy link
Contributor

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@microsoft-github-policy-service microsoft-github-policy-service bot added Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels May 31, 2023
@microsoft-github-policy-service
Copy link
Contributor

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@Rand-Random
Copy link
Author

Rand-Random commented Jun 9, 2023

@zadjii-msft - not sure if you would look at a closed issue without a ping


IMHO closing the issue makes the duplicate comment look like this is a completed task, as some issues in the comment aren't closed - so to me that would be confusing, I would believe looking at
image

that #8976 and #9933 are open tasks while #15455 is completed

BUT if thats how you want to do things, its totally up to you, so you do you


Had some time to look at this issue again, and wanted to do a "simple" fix based on the observed behaviour, I borrowed @elsaco code and did the following

internal class Program
{
    static void Main(string[] args)
    {
        for (var i = 0; i < 3; i++) 
            ConsoleEx.WriteLine(i.ToString().PadRight(119 + i, 'a'));

        Console.ReadKey();
    }
}

internal static class ConsoleEx
{
    #region Static Public Methods

    public static void WriteLine(string str)
    {
        //try to fix 
        if (str.Length is >= 119 and <= 121)
            str = str.PadRight(125);

        Console.WriteLine(str);
    }

    #endregion
}

the idea is if the length 120 is something special, I just add more whitespace characters (PadRight) to the string and hopefully this solve the issue.

Sadly, this didn't help and instead of the broken state of newlines "concatenated together" I am getting the different issue described in the comment #6901 (comment) "line breaks are introduced"
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug It either shouldn't be doing this or needs an investigation. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.
Projects
None yet
Development

No branches or pull requests

4 participants