pulumi/pkg
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
..
backend [cli] Emit JSON events for updates via --json flag (#8275) 2021-10-26 16:21:27 -07:00
cmd/pulumi [cli] Emit JSON events for updates via --json flag (#8275) 2021-10-26 16:21:27 -07:00
codegen [codegen/go] Slightly simplify enum type gen. (#8341) 2021-11-02 17:41:06 -07:00
engine [engine/test] Add a repro for #7786. (#8097) 2021-09-29 16:05:45 -07:00
graph [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
operations [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
resource Clarify error message language (#8188) 2021-10-11 15:21:58 -07:00
secrets [cli] Prevent regression in loading passphrase secrets provider from state (#6976) 2021-05-06 14:40:44 +01:00
testing/integration [cli] Emit JSON events for updates via --json flag (#8275) 2021-10-26 16:21:27 -07:00
util [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
version duplicate version to ensure linking is properly handled 2020-03-19 12:49:34 -07:00
go.mod Fix cmdutil.PrintTable to handle ansi escapes and non-byte glyphs (#8344) 2021-11-04 10:06:20 +00:00
go.sum Fix cmdutil.PrintTable to handle ansi escapes and non-byte glyphs (#8344) 2021-11-04 10:06:20 +00:00