Skip to content

Commit 46c280c

Browse files
authored
Merge pull request #769 from tsuyoshicho/fix/data-string-interpolation-float-fix
Data.String.Interpolation: fix float handling after 8.2.2948
2 parents 5828301 + ae14451 commit 46c280c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

autoload/vital/__vital__/Data/String/Interpolation.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ function! s:interpolate(string, ...) abort
1111
let expr = str[(s + len(s:_parser_config._ps)):(e - len(s:_parser_config._pend))]
1212
let V = s:_context_eval(expr, context)
1313
let str = (s > 0 ? str[0:(s-1)] : '') . V . str[(e+1):]
14-
let ps = s:_parse_first_idx_range(str, s + len(V))
15-
unlet V
14+
let vlen = type(V) is# v:t_string ? len(V) : len(string(V))
15+
let ps = s:_parse_first_idx_range(str, s + vlen)
1616
endwhile
1717
return str
1818
endfunction

test/Data/String/Interpolation.vimspec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ Describe Data.String.Interpolation
5151
End
5252
It handle reassignment different type
5353
Assert Equals(g:I.interpolate('${a} ${b}', {'a': 1, 'b': '1'}), '1 1')
54-
Throws /Vim(let):E806:/ g:I.interpolate('${a} ${b}', {'a': 1, 'b': 1.0E-6})
54+
if !has('patch-8.2.2948')
55+
Throws /Vim(let):E806:/ g:I.interpolate('${a} ${b}', {'a': 1, 'b': 1.0E-6})
56+
else
57+
Assert Equals(g:I.interpolate('${a} ${b}', {'a': 1, 'b': 1.0E-6}), '1 1.0e-6')
58+
endif
5559
End
5660
It doesn't raise Vim(let):E704: Funcref variable name must start with a capital
5761
Throws /Vim(let):E729:/ g:I.interpolate('${Funcref}', {'Funcref': function('InterpolationFunc')})

0 commit comments

Comments
 (0)