Skip to content

Commit fb2ad71

Browse files
committed
make DextraSpace effective regardless of DSyncWidth
1 parent 3ae7e1f commit fb2ad71

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

decor/decorator.go

+3-6
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ const (
1414
// | foo| b| DindentRight is not set
1515
DindentRight = 1 << iota
1616

17-
// DextraSpace bit adds extra space, makes sense with DSyncWidth only.
18-
// When DindentRight bit set, the space will be added to the right,
19-
// otherwise to the left.
17+
// DextraSpace bit adds extra indentation space.
2018
DextraSpace
2119

2220
// DSyncWidth bit enables same column width synchronization.
@@ -143,11 +141,10 @@ func (wc WC) Format(str string) (string, int) {
143141
viewWidth := runewidth.StringWidth(str)
144142
if wc.W > viewWidth {
145143
viewWidth = wc.W
144+
} else if (wc.C & DextraSpace) != 0 {
145+
viewWidth++
146146
}
147147
if (wc.C & DSyncWidth) != 0 {
148-
if (wc.C & DextraSpace) != 0 {
149-
viewWidth++
150-
}
151148
wc.wsync <- viewWidth
152149
viewWidth = <-wc.wsync
153150
}

0 commit comments

Comments
 (0)