Skip to content

Commit 26fbd6a

Browse files
committed
More complicated gsub to handle empty lines' unescaping correctly
1 parent b6c5ba2 commit 26fbd6a

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [0.4.30](https://github.com/ruby-debug/ruby-debug-ide/compare/v0.4.29...v0.4.30)
2+
3+
* unescaping of empty line fixed
4+
[RUBY-16600](https://youtrack.jetbrains.com/issue/RUBY-16600)
5+
16
## [0.4.29](https://github.com/ruby-debug/ruby-debug-ide/compare/v0.4.28...v0.4.29)
27

38
* Fixed problem with evaluating "%"

lib/ruby-debug-ide/command.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ def options
6666
end
6767

6868
def unescape_incoming(str)
69-
str.gsub(/((?:^|[^\\])(?:\\\\)*)\\n/, "\\1\n").
70-
gsub(/\\\\/, '\\')
69+
str.gsub(/((?:^|[^\\])(?:\\\\)*)((?:\\n)+)/) do |_|
70+
$1 + "\n" * ($2.size / 2)
71+
end.gsub(/\\\\/, '\\')
7172
end
7273
end
7374

test/ruby-debug/unescape_incoming_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ def test_something
2828
do_test('"\\\\\\n".size', "\"\\\n\".size")
2929
end
3030

31+
def test_two_newlines
32+
do_test('hello\n\nworld', "hello\n\nworld")
33+
end
34+
3135
def do_test(input, expected_result)
3236
assert_equal(expected_result, Debugger::Command.unescape_incoming(input))
3337
end

0 commit comments

Comments
 (0)