Skip to content

Commit

Permalink
Fix handling of backslash
Browse files Browse the repository at this point in the history
```
let x = '\x31'
echo $"${x}"
```

This should print "\x31" not "1".
  • Loading branch information
k-takata committed Feb 18, 2020
1 parent 8b25447 commit ff6882c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -3846,6 +3846,11 @@ escape_quotes_in_quote(char_u *x, int is_literal_string)
ga_concat(&result, (char_u *) "\\\"");
continue;
}
else if (!is_literal_string && *p == '\\')
{
ga_concat(&result, (char_u *) "\\\\");
continue;
}
ga_concatn(&result, p, mb_ptr2len(p));
}

Expand Down
2 changes: 2 additions & 0 deletions src/testdir/test_template_string.vim
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func Test_template_string_basic()
call assert_equal("'", $'$x')
let x = '"'
call assert_equal('"', $"$x")
let x = '\x31'
call assert_equal('\x31', $"$x")
let x20 = 20
call assert_equal('20', $'$x20')
let Fo_O0O = 30
Expand Down

0 comments on commit ff6882c

Please sign in to comment.