@@ -276,13 +276,6 @@ def self.for(output)
276
276
# default is \n.
277
277
DEFAULT_NEWLINE = "\n "
278
278
279
- # When generating spaces after a newline for indentation, by default we
280
- # generate one space per character needed for indentation. You can change this
281
- # behavior (for instance to use tabs) by passing a different genspace
282
- # procedure.
283
- DEFAULT_GENSPACE = -> ( n ) { " " * n }
284
- Ractor . make_shareable ( DEFAULT_GENSPACE ) if defined? ( Ractor )
285
-
286
279
# There are two modes in printing, break and flat. When we're in break mode,
287
280
# any lines will use their newline, any if-breaks will use their break
288
281
# contents, etc.
@@ -301,7 +294,7 @@ def self.for(output)
301
294
# This is a convenience method which is same as follows:
302
295
#
303
296
# begin
304
- # q = PrettierPrint.new(output, maxwidth, newline, &genspace )
297
+ # q = PrettierPrint.new(output, maxwidth, newline)
305
298
# ...
306
299
# q.flush
307
300
# output
@@ -311,10 +304,9 @@ def self.format(
311
304
output = "" . dup ,
312
305
maxwidth = 80 ,
313
306
newline = DEFAULT_NEWLINE ,
314
- genspace = DEFAULT_GENSPACE ,
315
307
indentation = DEFAULT_INDENTATION
316
308
)
317
- q = new ( output , maxwidth , newline , & genspace )
309
+ q = new ( output , maxwidth , newline )
318
310
yield q
319
311
q . flush ( indentation )
320
312
output
@@ -342,12 +334,6 @@ def self.format(
342
334
# This defaults to "\n", and should be String
343
335
attr_reader :newline
344
336
345
- # An object that responds to call that takes one argument, of an Integer, and
346
- # returns the corresponding number of spaces.
347
- #
348
- # By default this is: ->(n) { ' ' * n }
349
- attr_reader :genspace
350
-
351
337
# The stack of groups that are being printed.
352
338
attr_reader :groups
353
339
@@ -374,14 +360,12 @@ def self.format(
374
360
def initialize (
375
361
output = "" . dup ,
376
362
maxwidth = 80 ,
377
- newline = DEFAULT_NEWLINE ,
378
- &genspace
363
+ newline = DEFAULT_NEWLINE
379
364
)
380
365
@output = output
381
366
@buffer = Buffer . for ( output )
382
367
@maxwidth = maxwidth
383
368
@newline = newline
384
- @genspace = genspace || DEFAULT_GENSPACE
385
369
reset
386
370
end
387
371
@@ -429,7 +413,7 @@ def flush(base_indentation = DEFAULT_INDENTATION)
429
413
position = base_indentation
430
414
431
415
# Start the buffer with the base indentation level.
432
- buffer << genspace . call ( base_indentation ) if base_indentation > 0
416
+ buffer << " " * base_indentation if base_indentation > 0
433
417
434
418
# This is our command stack. A command consists of a triplet of an
435
419
# indentation level, the mode (break or flat), and a doc node.
@@ -513,7 +497,7 @@ def flush(base_indentation = DEFAULT_INDENTATION)
513
497
else
514
498
position -= buffer . trim!
515
499
buffer << newline
516
- buffer << genspace . call ( indent )
500
+ buffer << " " * indent
517
501
position = indent
518
502
end
519
503
when Indent
0 commit comments