File tree Expand file tree Collapse file tree 1 file changed +16
-17
lines changed
lib/ruby-debug-ide/commands Expand file tree Collapse file tree 1 file changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -13,23 +13,7 @@ def execute
13
13
total_lines = string_to_parse . count ( "\n " ) + 1
14
14
15
15
lexer = RubyLex . new
16
- io = StringIO . new ( string_to_parse )
17
-
18
- begin
19
- encoding = string_to_parse . encoding
20
- rescue
21
- encoding = 'None'
22
- end
23
-
24
- # for passing to the lexer
25
- io . instance_exec ( encoding ) do |string_encoding |
26
- @my_encoding = string_encoding
27
- def self . encoding
28
- @my_encoding
29
- end
30
- end
31
-
32
- lexer . set_input ( io )
16
+ lexer . set_input ( create_io_reader ( string_to_parse ) )
33
17
34
18
last_statement = ''
35
19
last_prompt = ''
@@ -53,6 +37,21 @@ def self.encoding
53
37
@printer . print_expression_info ( incomplete , last_prompt , last_indent )
54
38
end
55
39
40
+ def create_io_reader ( string_to_parse )
41
+ io = StringIO . new ( string_to_parse )
42
+
43
+ if string_to_parse . respond_to? ( :encoding )
44
+ io . instance_exec ( string_to_parse . encoding ) do |string_encoding |
45
+ @my_encoding = string_encoding
46
+ def self . encoding
47
+ @my_encoding
48
+ end
49
+ end
50
+ end
51
+
52
+ io
53
+ end
54
+
56
55
class << self
57
56
def help_command
58
57
"expression_info"
You can’t perform that action at this time.
0 commit comments