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

vrepl: fix output error of print and fn call (#15796)

This commit is contained in:
yuyi 2022-09-17 20:58:53 +08:00 committed by GitHub
parent afe7166346
commit 085a09ebdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -390,7 +390,10 @@ fn run_repl(workdir string, vrepl_prefix string) int {
source_code := r.current_source_code(false, false) + '\n$r.line\n'
os.write_file(temp_file, source_code) or { panic(err) }
s := repl_run_vfile(temp_file) or { return 1 }
print_output(s.output)
if s.output.len > r.last_output.len {
cur_line_output := s.output[r.last_output.len..]
print_output(cur_line_output)
}
} else {
mut temp_line := r.line
func_call, fntype := r.function_call(r.line)
@ -441,7 +444,10 @@ fn run_repl(workdir string, vrepl_prefix string) int {
source_code := r.current_source_code(false, false) + '\n$temp_line\n'
os.write_file(temp_file, source_code) or { panic(err) }
s := repl_run_vfile(temp_file) or { return 1 }
print_output(s.output)
if s.output.len > r.last_output.len {
cur_line_output := s.output[r.last_output.len..]
print_output(cur_line_output)
}
continue
}
mut temp_source_code := ''

View File

@ -0,0 +1,10 @@
println('hello')
fn abc(x int) { println(x) }
abc(123)
abc(456)
println('hello')
===output===
hello
123
456
hello