@@ -50,6 +50,8 @@ public function __invoke(ExplorerPrompt $prompt): string
50
50
return $ this ->prompt ->highlighted === $ index ? $ this ->inverse ($ label ) : $ label ;
51
51
});
52
52
53
+ $ this ->minWidth = $ this ->prompt ->terminal ()->cols ();
54
+
53
55
if ($ this ->prompt ->header ) {
54
56
$ body ->prepend (
55
57
$ this ->makeColumn (
@@ -59,8 +61,6 @@ public function __invoke(ExplorerPrompt $prompt): string
59
61
);
60
62
}
61
63
62
- $ this ->minWidth = $ this ->prompt ->terminal ()->cols ();
63
-
64
64
$ this ->when (
65
65
$ this ->prompt ->showFilterBox (),
66
66
fn () => $ this ->box (
@@ -77,13 +77,17 @@ public function __invoke(ExplorerPrompt $prompt): string
77
77
78
78
protected function makeColumn (array $ values ): string
79
79
{
80
- return collect ($ values )
81
- ->values ()
82
- ->map (function ($ item , $ index ) {
83
- $ width = $ this ->calculateColumnWidth ($ index );
84
- return mb_str_pad ($ item ?? '' , $ width , ' ' , $ this ->prompt ->getColumnAlignment ($ index )->toPadding ());
85
- })
86
- ->join (' ' );
80
+ return mb_substr (
81
+ collect ($ values )
82
+ ->values ()
83
+ ->map (function ($ item , $ index ) {
84
+ $ width = $ this ->calculateColumnWidth ($ index );
85
+ return mb_str_pad ($ item ?? '' , $ width , ' ' , $ this ->prompt ->getColumnAlignment ($ index )->toPadding ());
86
+ })
87
+ ->join (' ' ),
88
+ 0 ,
89
+ $ this ->widthToFill ()
90
+ );
87
91
}
88
92
89
93
protected function getTitle (): string
@@ -98,7 +102,7 @@ protected function getTitle(): string
98
102
99
103
protected function widthToFill (): int
100
104
{
101
- return $ this ->prompt ->terminal ()->cols () - 11 ;
105
+ return $ this ->prompt ->terminal ()->cols () - 8 ;
102
106
}
103
107
104
108
protected function calculateColumnWidth (int $ column ): int
@@ -113,7 +117,7 @@ protected function calculateColumnWidth(int $column): int
113
117
$ columnsWithCustomWidth = $ this ->prompt ->countColumnsWithFixedWidth ();
114
118
$ widthPerColumn = floor ($ widthToFill / ($ this ->columnCount ($ this ->prompt ) - $ columnsWithCustomWidth ));
115
119
116
- return $ this ->prompt ->getColumnMinWidth ($ column ) + $ widthPerColumn ;
120
+ return $ this ->prompt ->getColumnMinWidth ($ column ) + ( $ widthPerColumn > 0 ? $ widthPerColumn : 0 ) ;
117
121
}
118
122
119
123
protected function columnCount (): int
0 commit comments