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

Add workaround for garbled utf-8 characters on linux #261

Merged
merged 1 commit into from
Jul 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/PrettyPrompt/Panes/CodePane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public CodePane(IConsole console, PromptConfiguration configuration, IPromptCall
this.promptCallbacks = promptCallbacks;
this.clipboard = clipboard;

TopCoordinate = console.CursorTop;
MeasureConsole();

Document = new Document();
Expand Down Expand Up @@ -389,10 +390,14 @@ void AppendFiltered(StringBuilder sb, string line)

internal void MeasureConsole()
{
TopCoordinate = Math.Max(0, console.CursorTop - console.WindowTop - Cursor.Row);
CodeAreaWidth = Math.Max(0, console.BufferWidth - configuration.Prompt.Length);
CodeAreaHeight = Math.Max(0, console.WindowHeight - TopCoordinate);

if(OperatingSystem.IsWindows())
{
// ideally we'd update this in Linux too, but https://github.com/dotnet/runtime/issues/88343 prevents it.
// see https://github.com/waf/PrettyPrompt/pull/231 for why we need this line at all.
TopCoordinate = Math.Max(0, console.CursorTop - console.WindowTop - Cursor.Row);
}
this.CodeAreaWidth = Math.Max(0, console.BufferWidth - configuration.Prompt.Length);
this.CodeAreaHeight = Math.Max(0, console.WindowHeight - this.TopCoordinate);
Debug.WriteLine($"CodeAreaHeight: {CodeAreaHeight} TopCoordinate: {TopCoordinate}");
}

Expand Down