make DextraSpace effective regardless of DSyncWidth
Vladimir Bauer
2 years ago
| 13 | 13 | // | foo| b| DindentRight is not set |
| 14 | 14 | DindentRight = 1 << iota |
| 15 | 15 | |
| 16 | // DextraSpace bit adds extra space, makes sense with DSyncWidth only. | |
| 17 | // When DindentRight bit set, the space will be added to the right, | |
| 18 | // otherwise to the left. | |
| 16 | // DextraSpace bit adds extra indentation space. | |
| 19 | 17 | DextraSpace |
| 20 | 18 | |
| 21 | 19 | // DSyncWidth bit enables same column width synchronization. |
| 142 | 140 | viewWidth := runewidth.StringWidth(str) |
| 143 | 141 | if wc.W > viewWidth { |
| 144 | 142 | viewWidth = wc.W |
| 143 | } else if (wc.C & DextraSpace) != 0 { | |
| 144 | viewWidth++ | |
| 145 | 145 | } |
| 146 | 146 | if (wc.C & DSyncWidth) != 0 { |
| 147 | if (wc.C & DextraSpace) != 0 { | |
| 148 | viewWidth++ | |
| 149 | } | |
| 150 | 147 | wc.wsync <- viewWidth |
| 151 | 148 | viewWidth = <-wc.wsync |
| 152 | 149 | } |