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

repl: fix for-loop/if statement duplicate printing bug

This commit is contained in:
Ned Palacios 2020-05-25 16:35:55 +08:00 committed by GitHub
parent 96808a0e2a
commit 3aeaa24df6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -219,6 +219,13 @@ fn run_repl(workdir string, vrepl_prefix string) {
if temp_line.starts_with('import ') || temp_line.starts_with('#include ') {
temp_source_code = '${temp_line}\n' + r.current_source_code(false)
} else {
for i, l in r.lines {
if (l.starts_with('for ') || l.starts_with('if ')) && l.contains('println') {
r.lines.delete(i)
break
}
}
temp_source_code = r.current_source_code(true) + '\n${temp_line}\n'
}
os.write_file(temp_file, temp_source_code)