File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -234,9 +234,15 @@ protected function formatLines($lines)
234
234
*/
235
235
function fixSpaces ($ matches )
236
236
{
237
- $ count = strlen ($ matches ['0 ' ]);
238
- if ($ count == 0 ) {
239
- return '' ;
237
+ $ buffer = '' ;
238
+ foreach ($ matches as $ spaces ){
239
+ $ count = strlen ($ spaces );
240
+ if ($ count == 0 ) {
241
+ continue ;
242
+ }
243
+ $ div = floor ($ count / 2 );
244
+ $ mod = $ count % 2 ;
245
+ $ buffer .= str_repeat (' ' , $ div ).str_repeat ('  ' , $ mod );
240
246
}
241
247
242
248
$ div = floor ($ count / 2 );
@@ -252,7 +258,15 @@ function fixSpaces($matches)
252
258
*/
253
259
private function expandTabs ($ line )
254
260
{
255
- return str_replace ("\t" , str_repeat (' ' , $ this ->options ['tabSize ' ]), $ line );
261
+ $ tabSize = $ this ->options ['tabSize ' ];
262
+ while (($ pos = strpos ($ line , "\t" )) !== FALSE ){
263
+ $ left = substr ($ line , 0 , $ pos );
264
+ $ right = substr ($ line , $ pos + 1 );
265
+ $ length = $ tabSize - ($ pos % $ tabSize );
266
+ $ spaces = str_repeat (' ' , $ length );
267
+ $ line = $ left .$ spaces .$ right ;
268
+ }
269
+ return $ line ;
256
270
}
257
271
258
272
/**
You can’t perform that action at this time.
0 commit comments