irb icon indicating copy to clipboard operation
irb copied to clipboard

Auto formatting should be disabled by default

Open heaven opened this issue 2 years ago • 2 comments

Description

After upgrading to ruby 2.7.6 our IRB got broken, copy and pasting a long string was slow, if you need to paste a multiline test in a middle of a string that also didn't work. We had to upgrade the IRB gem to 1.5.0, now it always automatically formats the output, which I don't need.

Now the output looks like this, which is quite annoying. Previously, when I needed a formatted output I was able to use pp. Can't find a way to disable this with Heroku also.

2.7.6 :002 > stats = [[17144, 514], [17638, 522], [16796, 525], [16838, 535], [131, 538], [17080, 542], [15866, 573], [16924, 575], [17594, 605], [943, 611], [17379, 612], [17056, 640], [16795, 681], [17481, 686], [13529, 692], [17286, 697], [17640, 717], [13852, 720], [1726, 749], [14243, 758], [13785, 771], [14342, 779], [13627, 861], [27, 867], [13594, 871], [17285, 940], [17139, 944], [14286, 982], [15796, 995], [14180, 1024], [17583, 1130], [15918, 1207], [15664, 1256], [17066, 1372], [16243, 1373], [17198, 1400], [17213, 1516], [17622, 1539], [17467, 1621], [17122, 1700], [15739, 1752], [16939, 1760], [16940, 1843], [15510, 1929], [17164, 1963], [15667, 2033], [17001, 2633], [17493, 3372], [16325, 3535], [16485, 3763], [17580, 4002], [16480, 4495], [16952, 4604], [17114, 4860], [17046, 5012], [17401, 5123], [17047, 5268], [13653, 5379], [16138, 5391], [17070, 6030], [15255, 6387], [63, 6536], [17476, 6837], [15682, 7263], [16446, 8721], [15867, 9081], [17465, 9207], [17307, 9836], [17414, 10553], [14762, 12058], [17639, 15060], [14932, 19581], [17099, 21540], [17437, 25341], [12985, 31836], [17666, 31848], [17439, 35802], [17668, 178481], [17667, 247517]]
 =>
[[17144, 514],
...
2.7.6 :003 > stats
 =>
[[17144, 514],
 [17638, 522],
 [16796, 525],
 [16838, 535],
 [131, 538],
 [17080, 542],
 [15866, 573],
 [16924, 575],
 [17594, 605],
 [943, 611],
 [17379, 612],
 [17056, 640],
 [16795, 681],
 [17481, 686],
 [13529, 692],
 [17286, 697],
 [17640, 717],
 [13852, 720],
 [1726, 749],
 [14243, 758],
 [13785, 771],
 [14342, 779],
 [13627, 861],
 [27, 867],
 [13594, 871],
 [17285, 940],
 [17139, 944],
 [14286, 982],
 [15796, 995],
 [14180, 1024],
 [17583, 1130],
 [15918, 1207],
 [15664, 1256],
 [17066, 1372],
 [16243, 1373],
 [17198, 1400],
 [17213, 1516],
 [17622, 1539],
 [17467, 1621],
 [17122, 1700],
 [15739, 1752],
 [16939, 1760],
 [16940, 1843],
 [15510, 1929],
 [17164, 1963],
 [15667, 2033],
 [17001, 2633],
 [17493, 3372],
 [16325, 3535],
 [16485, 3763],
 [17580, 4002],
 [16480, 4495],
 [16952, 4604],
 [17114, 4860],
 [17046, 5012],
 [17401, 5123],
 [17047, 5268],
 [13653, 5379],
 [16138, 5391],
 [17070, 6030],
 [15255, 6387],
 [63, 6536],
 [17476, 6837],
 [15682, 7263],
 [16446, 8721],
 [15867, 9081],
 [17465, 9207],
 [17307, 9836],
 [17414, 10553],
 [14762, 12058],
 [17639, 15060],
 [14932, 19581],
 [17099, 21540],
 [17437, 25341],
 [12985, 31836],
 [17666, 31848],
 [17439, 35802],
 [17668, 178481],
 [17667, 247517]]

Result of irb_info

2.7.6 :001 > irb_info
 =>
Ruby version: 2.7.6
IRB version: irb 1.5.0 (2022-11-20)
InputMethod: ReadlineInputMethod with ext/readline 8.2
.irbrc path: /Users/heaven/.rvm/rubies/ruby-2.7.6/.irbrc
RUBY_PLATFORM: arm64-darwin22
East Asian Ambiguous Width: 1

Terminal Emulator

iTerm2

Setting Files

My ~/.irbrc

IRB.conf[:USE_MULTILINE] = false

heaven avatar Nov 21 '22 18:11 heaven

Another problem with truncation, while I understand the reason on large objects such as Array or Hash, doing this on AR instances like this

2.7.6 :006 > site = Site.find(523)
  Site Load (1.3ms)  SELECT  "sites".* FROM "sites" WHERE "sites"."deleted_at" IS NULL AND "sites"."id" = $1 LIMIT $2  [["id", 523], ["LIMIT", 1]]
 =>
#<Site:0x000000010b7f08a8
...

Just doesn't make any sense to me. And even on Arrays doing things like

2.7.6 :002 > stats = [[17144, 514], [17638, 522], ...]
 =>
[[17144, 514],
...

Is barely informative. It would make more sense to show Array(123), where 123 is the size of an array.

heaven avatar Nov 22 '22 08:11 heaven

The output format can be customized by irbrc file

# ~/.irbrc
IRB.conf[:INSPECT_MODE] = :inspect

tompng avatar Aug 13 '24 20:08 tompng