-
-
Notifications
You must be signed in to change notification settings - Fork 515
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
AnsiConsole.Live‘s working results are inconsistent. #1688
Comments
@NMSAzulX You will need to provide a fully reproducable example for us to be able to determine what the problem is. |
Console.OutputEncoding = System.Text.Encoding.UTF8;
Console.InputEncoding = System.Text.Encoding.UTF8;
Console.SetWindowSize(100, 33);
var table = new Table
{
Border = TableBorder.Simple
};
table.AddColumn(new TableColumn("Index").Centered());
table.AddColumn(new TableColumn("Name").Centered());
table.AddColumn(new TableColumn("Path").LeftAligned());
table.Centered();
ConcurrentDictionary<int, int> data = [];
CancellationTokenSource cancellation = new();
var result =Task.Run(()=>Parallel.For(0, 50, (i) =>
{
Thread.Sleep(100);
data[i] = i;
}));
Task.Run(() =>
{
while (!result.IsCompleted)
{
Thread.Sleep(200);
}
cancellation.Cancel();
});
string path = "g:\\1111111111.1111111111\\11111111111112.2111111111111\\3.3\\4,4\\5\\6\\7\\8.csproj";
AnsiConsole
.Live(table)
.AutoClear(false)
.Start((ctx) => {
var tempList = data.OrderBy(item => item.Value).ToArray();
while (!cancellation.IsCancellationRequested)
{
table.Rows.Clear();
for (int i = 0; i < tempList.Length; i++)
{
var pathText = new TextPath(path)
{
RootStyle = new Style(foreground: Color.LightSteelBlue3),
StemStyle = new Style(foreground: Color.MediumPurple3_1),
LeafStyle = new Style(foreground: Color.LightSteelBlue3),
SeparatorStyle = new Style(foreground: Color.LightSteelBlue3)
};
table.AddRow(
new Markup($"[chartreuse3_1] {tempList[i].Value}[/]"),
new Markup($"[chartreuse3_1] NNNNNNNNNNNNNaaaaaaaaaaaaaNNNNNNNNNNNNNNNName [/]"),
pathText
);
}
Thread.Sleep(100);
ctx.Refresh();
tempList = data.OrderBy(item => item.Value).ToArray();
}
table.Rows.Clear();
for (int i = 0; i < tempList.Length; i++)
{
var pathText = new TextPath(path)
{
RootStyle = new Style(foreground: Color.LightSteelBlue3),
StemStyle = new Style(foreground: Color.MediumPurple3_1),
LeafStyle = new Style(foreground: Color.LightSteelBlue3),
SeparatorStyle = new Style(foreground: Color.LightSteelBlue3)
};
table.AddRow(
new Markup($"[chartreuse3_1] {tempList[i].Value}[/]"),
new Markup($"[chartreuse3_1] NNNNNNNNNNNNNaaaaaaaaaaaaaNNNNNNNNNNNNNNNName [/]"),
pathText
);
}
ctx.Refresh();
}); I reproduced this bug. It is caused by the file path. |
Information
Describe the bug
Data is a result set generated by concurrent logic.
It will keep fetching data until the token is cancelled.
Every time new data is fetched, the contents in the table rows will be cleared and re-rendered.
The problem is: When Rows is empty,
ctx.Refresh()
can still render data. Why?The result of the above code is that the table renders four rows of data.
To Reproduce
Expected behavior
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
The text was updated successfully, but these errors were encountered: