spectreconsole / spectre.console

A .NET library that makes it easier to create beautiful console applications.
https://spectreconsole.net
MIT License
9.17k stars 472 forks source link

Unknown console width results in 80 width, becomes hard to read when writing errors for visual studio #1162

Open madeso opened 1 year ago

madeso commented 1 year ago

Information

Describe the bug When running a spectre console app through visual studio as a custom build, System.Console.BufferWidth throws a IOException and sets the console width to 80 (I'm guessing based on reading this and this) . This makes sense in general, but when outputting errors (and especially when including the path to the file) , lines can get pretty long, and as far as I can tell visual studio only reads the first line when parsing the output for the error list.

Visual studio error list: image

Output from app (Visual studio output):

1>C:\dev\euphoria\libs\core\src\core\aabb.h(22): error : Members for
1>euphoria::core::Aabb are orderd badly, can't go from Calculators (vec3f
1>wrap(const vec3f &vec) const) to Manipulators (void extend(const vec3f &vec))!

To Reproduce Run a spectre enabled program that prints a line longer than 80 as a build step from visual studio.

I used the following to trigger a run via cmake in another solution

add_custom_target(run_spectre_app path_to_binary)

Expected behavior I'm honestly not sure what I expect. Like I said, 80 makes sense in general but it would be great if the word wrap could be disabled or the default could be changed for the special cases when a console can't be detected.

For example:

AnsiConsole.DefaultWidth = 8000;
// or
AnsiConsole.DefaultWidth = AnsiConsole.NoWordwrap;

Additional context For a workaround I detect if there isn't a console attached and switch to Console.WriteLine, not a elegant solution but it works.

image


Please upvote :+1: this issue if you are interested in it.

Kralizek commented 1 year ago

I think I'm having the same problem.

I have a console application that outputs a very long string as part of a yaml property. When piping the output into a file, the line is wrapped. The same doesn't happen when running the program without piping.

stefc commented 1 year ago

I also want to increase the width from 80 to 120 characters !