Skip to content

Commit f5d6889

Browse files
committed
Don't try to format lists.
1 parent cf73ace commit f5d6889

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

lib/code/formatter.ex

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,9 @@ module Code::Formatter
1010
end
1111

1212
def format_object(object)
13-
if object != [] && Erlang.io_lib.printable_list(object)
14-
object.flatten.to_bin
15-
else
16-
try
17-
object.inspect
18-
catch 'error: 'undef
19-
"[Could not inspect object]"
20-
end
21-
end
13+
object.inspect
14+
catch 'error: 'undef
15+
"[Could not inspect object]"
2216
end
2317

2418
def format_catch('error, {'badsyntax, {line, filename, error, token}})

test/elixir/code/formatter_test.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module Code::FormatterTest
77
"[]" = Code::Formatter.format_object([])
88
"{1,2,3}" = Code::Formatter.format_object({1,2,3})
99
"[1,2,3]" = Code::Formatter.format_object([1,2,3])
10-
"abc" = Code::Formatter.format_object([$a,$b,$c])
10+
"[97,98,99]" = Code::Formatter.format_object([$a,$b,$c])
11+
"\"abc\"" = Code::Formatter.format_object("abc")
1112
end
1213
end

0 commit comments

Comments
 (0)