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:
parent
afe7166346
commit
085a09ebdb
@ -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 := ''
|
||||
|
10
vlib/v/tests/repl/print_and_fn_call.repl
Normal file
10
vlib/v/tests/repl/print_and_fn_call.repl
Normal file
@ -0,0 +1,10 @@
|
||||
println('hello')
|
||||
fn abc(x int) { println(x) }
|
||||
abc(123)
|
||||
abc(456)
|
||||
println('hello')
|
||||
===output===
|
||||
hello
|
||||
123
|
||||
456
|
||||
hello
|
Loading…
Reference in New Issue
Block a user