Fix panic when using sqlite as history backend (#469)

Fixes nushell/nushell#6251
This commit is contained in:
nibon7 2022-08-27 18:59:55 +08:00 committed by GitHub
parent d4ab1a753f
commit 069d902bcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,7 +24,11 @@ impl Hinter for DefaultHinter {
.expect("todo: error handling")
.get(0)
.map_or_else(String::new, |entry| {
entry.command_line[line.len()..].to_string()
entry
.command_line
.get(line.len()..)
.unwrap_or_default()
.to_string()
})
} else {
String::new()