2
Vote

Calculated Width is still wrong --- causing awkward wrapping

description

The host is still calculating the width wrong that it gives to PowerShell. The output of this shouldn't wrap, but does:

"A" * $Host.UI.RawUI.WindowSize.Width

comments

nsulikow wrote Jan 24, 2012 at 10:17 PM

I wonder if the solution to this would be to return a very large width (say 10000).... since the RichTextBox control would already take care of wrapping long lines...

Jaykul wrote Jan 24, 2012 at 11:15 PM

I tried that initially, but it totally wrecks the output when it's table formatted. To see what I mean try piping through Out-String -Width 10000

nsulikow wrote Jan 26, 2012 at 5:10 AM

Good point. I think there is something weird in the code, as the character width seems to be hardcoded. I would explore using System.Windows.Media.TextFormatting.TextFormatter to calculate the text width...

nsulikow wrote Jan 26, 2012 at 3:41 PM

Sorry, I meant: FormattedText