1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: fix weird bug with tabs in string inpertolation

This commit is contained in:
Uwe Krüger 2020-06-24 20:40:29 +02:00 committed by GitHub
parent 9a77c0ab81
commit eb68c222fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -88,7 +88,7 @@ fn (mut f Fmt) find_comment(line_nr int) {
}
*/
pub fn (mut f Fmt) write(s string) {
if !f.buffering || f.is_inside_interp {
if !f.buffering {
if f.indent > 0 && f.empty_line {
if f.indent < tabs.len {
f.out.write(tabs[f.indent])
@ -153,6 +153,10 @@ fn (mut f Fmt) adjust_complete_line() {
if f.penalties[j] <= 1 && f.precedences[j] == precedence {
sub_expr_end_idx = j
break
} else if f.precedences[j] < precedence {
// we cannot form a sensible subexpression
len_sub_expr = C.INT32_MAX
break
} else {
len_sub_expr += f.expr_bufs[j+1].len
}

View File

@ -46,6 +46,10 @@ fn main() {
if a + b + r * d + a + b + r * d > a + b + r * d + a * b + r {
println('ok')
}
v_str := 'v'
s := []string{}
s << ' `$v_str`'
println(s)
}
fn gen_str_for_multi_return(mut g gen.Gen, info table.MultiReturn, styp, str_fn_name string) {

View File

@ -56,6 +56,10 @@ fn main() {
a*b+r {
println('ok')
}
v_str := 'v'
s := []string{}
s << ' `$v_str`'
println(s)
}
fn gen_str_for_multi_return(mut g gen.Gen,