Skip to content

Commit b204643

Browse files
committed
added indent and prompt type output for expression_info
1 parent 1d19a95 commit b204643

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

lib/ruby-debug-ide/commands/expression_info.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ def regexp
1010

1111
def execute
1212
string_to_parse = @match.post_match.gsub("\\n", "\n") + "\n\n\n"
13+
total_lines = string_to_parse.count("\n") + 1
1314

1415
lexer = RubyLex.new
1516
io = StringIO.new(string_to_parse)
@@ -22,9 +23,17 @@ def self.encoding
2223
end
2324

2425
lexer.set_input(io)
25-
lexer.set_prompt {|ltype, indent, continue, lineno| }
2626

2727
last_statement = ''
28+
last_prompt = ''
29+
last_indent = 0
30+
lexer.set_prompt do |ltype, indent, continue, lineno|
31+
next if (lineno >= total_lines)
32+
33+
last_prompt = ltype || ''
34+
last_indent = indent
35+
end
36+
2837
lexer.each_top_level_statement do |line, line_no|
2938
last_statement = line
3039
end
@@ -34,7 +43,13 @@ def self.encoding
3443
incomplete = false
3544
end
3645

37-
@printer.print_pp("<expressionInfo incomplete=\"#{incomplete.to_s}\"></expressionInfo>")
46+
@printer.print_pp <<-EOF.gsub(/\n */, ' ').gsub(/>\s+</m, '><').strip
47+
<expressionInfo
48+
incomplete="#{incomplete.to_s}"
49+
prompt="#{last_prompt.gsub('"', '&quot;')}"
50+
indent="#{last_indent.to_s}">
51+
</expressionInfo>
52+
EOF
3853
end
3954

4055
class << self

0 commit comments

Comments
 (0)