pulumi/sdk/go/common
Fraser Waters b58c39476f
Fix cmdutil.PrintTable to handle ansi escapes and non-byte glyphs (#8344)
Fixes two bugs in how padding was calculated in PrintTable.

Firstly we remove all ANSI escape codes from the string before measuring
how wide it is. Secondly we measure glyph count (using rivo/uniseg) not
byte or rune count of the string.

Together these fix the padding/alignment issues I saw when using
PrintTable with plan output. They also slightly change the layout of
"pulumi stack", for example the below is printed with current master and
has 6 characters of space for padding between SecurityGroup and
web-secgrp:

```
Current stack resources (4):
    TYPE                                        NAME
    pulumi:pulumi:Stack                         aws-cs-webserver-test
    ├─ aws:ec2/securityGroup:SecurityGroup      web-secgrp
    ├─ aws:ec2/instance:Instance                web-server-www
    └─ pulumi:providers:aws                     default_4_25_0
```

While printed with this commit you only get 2 characters of space for
padding (which is correct, the column gap is set to "  "):
```
Current stack resources (4):
    TYPE                                    NAME
    pulumi:pulumi:Stack                     aws-cs-webserver-test
    ├─ aws:ec2/securityGroup:SecurityGroup  web-secgrp
    ├─ aws:ec2/instance:Instance            web-server-www
    └─ pulumi:providers:aws                 default_4_25_0
```
2021-11-04 10:06:20 +00:00
..
apitype [apitype] Add a JSON schema for deployments. (#8002) 2021-09-21 21:37:06 -07:00
constant expose execution kind via update metadata (#5258) 2020-08-31 09:07:59 -07:00
diag reformat error message string (#8284) 2021-10-26 14:55:25 -06:00
encoding Improve error message and add test for #1440 (#8268) 2021-10-26 16:55:52 +01:00
resource Update pkg -> sdk dependency (#8346) 2021-11-03 11:25:20 -07:00
testing Update pkg -> sdk dependency (#8346) 2021-11-03 11:25:20 -07:00
tokens [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
tools [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
util Fix cmdutil.PrintTable to handle ansi escapes and non-byte glyphs (#8344) 2021-11-04 10:06:20 +00:00
version move pkg/version -> sdk/go/common/version 2020-03-18 15:25:25 -07:00
workspace Update pkg -> sdk dependency (#8346) 2021-11-03 11:25:20 -07:00