diff options
| -rw-r--r-- | mrbgems/mruby-compiler/core/parse.y | 4 | ||||
| -rw-r--r-- | mrbgems/mruby-compiler/core/y.tab.c | 4 | ||||
| -rw-r--r-- | test/t/literals.rb | 5 |
3 files changed, 9 insertions, 4 deletions
diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index 4a031abde..ebb18767a 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -4700,12 +4700,12 @@ parse_string(parser_state *p) pylval.nd = nd; if (head) { hinf->indented = push(hinf->indented, cons((node*)spaces, nd->cdr)); - if ((hinf->indent == -1 || spaces < hinf->indent) && (!empty || !hinf->line_head)) + if ((hinf->indent == -1 || spaces < hinf->indent) && (!empty || !line_head)) hinf->indent = spaces; } return tHD_STRING_MID; } - if (hinf && hinf->line_head) { + if (hinf && hinf->line_head && empty) { if (ISSPACE(c)) { if (hinf->indent_char == -1) hinf->indent_char = c; diff --git a/mrbgems/mruby-compiler/core/y.tab.c b/mrbgems/mruby-compiler/core/y.tab.c index ea3cf2db7..2305c2bb6 100644 --- a/mrbgems/mruby-compiler/core/y.tab.c +++ b/mrbgems/mruby-compiler/core/y.tab.c @@ -11085,12 +11085,12 @@ parse_string(parser_state *p) pylval.nd = nd; if (head) { hinf->indented = push(hinf->indented, cons((node*)spaces, nd->cdr)); - if ((hinf->indent == -1 || spaces < hinf->indent) && (!empty || !hinf->line_head)) + if ((hinf->indent == -1 || spaces < hinf->indent) && (!empty || !line_head)) hinf->indent = spaces; } return tHD_STRING_MID; } - if (hinf && hinf->line_head) { + if (hinf && hinf->line_head && empty) { if (ISSPACE(c)) { if (hinf->indent_char == -1) hinf->indent_char = c; diff --git a/test/t/literals.rb b/test/t/literals.rb index dad5c872a..682e5317a 100644 --- a/test/t/literals.rb +++ b/test/t/literals.rb @@ -190,6 +190,10 @@ QQ2 \tvvv vvv VVV + v3 = <<~VVV + v v v + vvv + VVV w = %W( 1 #{<<WWW} 3 www @@ -232,6 +236,7 @@ ZZZ assert_equal ["u1u\n", "u2u\n", "u\#{3}u\n"], u assert_equal "\nvvv\nvvv\n", v1 assert_equal "\tvvv\n vvv\n", v2 + assert_equal "v v v\n vvv\n", v3 assert_equal ["1", "www\n", "3", "4", "5"], w assert_equal [1, "foo 222 333\n 444\n5\n bar\n6\n", 9], x assert_equal "", z |
