Skip to content

Commit da413e4

Browse files
viuginick1valich
authored andcommitted
hix hashes with long keys/values
1 parent f100c42 commit da413e4

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

lib/ruby-debug-ide/xml_printer.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def print_hash(hash)
147147
if k.class.name == "String"
148148
name = '\'' + k + '\''
149149
else
150-
name = k.to_s
150+
name = exec_with_allocation_control(k, ENV['DEBUGGER_MEMORY_LIMIT'].to_i, ENV['INSPECT_TIME_LIMIT'].to_i, :to_s, OverflowMessageType::EXCEPTION_MESSAGE)
151151
end
152152
print_variable(name, hash[k], 'instance')
153153
}
@@ -462,8 +462,19 @@ def compact_array_str(value)
462462
end
463463

464464
def compact_hash_str(value)
465-
slice = value.sort_by {|k, _| k.to_s}[0..5]
466-
compact = slice.map {|kv| "#{kv[0]}: #{handle_binary_data(kv[1])}"}.join(", ")
465+
keys_strings = Hash.new
466+
467+
slice = value.sort_by do |k, _|
468+
keys_string = exec_with_allocation_control(k, ENV['DEBUGGER_MEMORY_LIMIT'].to_i, ENV['INSPECT_TIME_LIMIT'].to_i, :to_s, OverflowMessageType::SPECIAL_SYMBOL_MESSAGE)
469+
keys_strings[k] = keys_string
470+
keys_string
471+
end[0..5]
472+
473+
compact = slice.map do |kv|
474+
key_string = keys_strings[kv[0]]
475+
value_string = exec_with_allocation_control(kv[1], ENV['DEBUGGER_MEMORY_LIMIT'].to_i, ENV['INSPECT_TIME_LIMIT'].to_i, :to_s, OverflowMessageType::SPECIAL_SYMBOL_MESSAGE)
476+
"#{key_string}: #{handle_binary_data(value_string)}"
477+
end.join(", ")
467478
"{" + compact + (slice.size != value.size ? ", ..." : "") + "}"
468479
end
469480

0 commit comments

Comments
 (0)