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

readline: give the possibility to ignore the empty line in the history (#13452)

This commit is contained in:
Vincenzo Palazzo
2022-02-13 23:12:25 +01:00
committed by GitHub
parent 57e850e932
commit bf11df40e2
3 changed files with 12 additions and 4 deletions

View File

@@ -28,6 +28,7 @@ mut:
prompt string
prompt_offset int
previous_lines [][]rune
skip_empty bool // skip the empty lines when calling .history_previous()
search_index int
is_tty bool
}

View File

@@ -551,9 +551,14 @@ fn (mut r Readline) history_previous() {
r.previous_lines[0] = r.current
}
r.search_index++
r.current = r.previous_lines[r.search_index]
r.cursor = r.current.len
r.refresh_line()
prev_line := r.previous_lines[r.search_index]
if r.skip_empty && prev_line == [] {
r.history_previous()
} else {
r.current = prev_line
r.cursor = r.current.len
r.refresh_line()
}
}
// history_next sets current line to the content of the next line in the history buffer.