Skip to content

Improve workspaces inspect truncation - #1248

Open
tompng wants to merge 1 commit into
ruby:masterfrom
tompng:pushws_inspect_closing
Open

Improve workspaces inspect truncation#1248
tompng wants to merge 1 commit into
ruby:masterfrom
tompng:pushws_inspect_closing

Conversation

@tompng

@tompng tompng commented Sep 7, 2026

Copy link
Copy Markdown
Member

Supports #<ClassName...>, "long_string...", [array...], {key: value...}, (1/12345...), and /long_regexp.../.
If inspect ends with other character, simply use "..." as an omission string.

> pushws "a"*100
> pushws [1]*100
Before: [main, "aaaaaaaaaaaaaaaaaa...>, [1, 1, 1, 1, 1, 1, ...>]
After:  [main, "aaaaaaaaaaaaaaaaaa...", [1, 1, 1, 1, 1, 1, ...]]

Limitation: parens/quotes may not match.

> pushws 1+1ri/2**100
> pushws ["abc"]*10
[main, (1+(1/1267650600228...), ["abc", "abc", "abc...]]

Supports `#<ClassName...>`, `"long_string..."`, `[array...]`, `{key: value...}`, (1/12345...), and `/long_regexp.../`.
If inspect ends with other character, simply use `"..."` as an omission string.
@tompng
tompng force-pushed the pushws_inspect_closing branch from 245b890 to 88a4ba8 Compare September 7, 2026 14:46

@GabrielLidenor GabrielLidenor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot approve it, but it looks great to me.

Comment thread lib/irb/command/pushws.rb
# #<Object...>, [array...], {hash...}, (123/456...), "string...", /regexp.../
# Other objects will be truncated without a closing character.
closing = nil unless '>]})"/'.include?(closing)
obj_inspection = "#{obj_inspection[0, threshold - 1]}...#{closing}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be simplified a bit, to remove the zero by doing

obj_inspection = "#{obj_inspection[...threshold - 1]}...#{closing}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants