Adapt for improved history isolation in reedline (#10402)

Depends on https://github.com/nushell/reedline/pull/634

---------

Co-authored-by: WindSoilder <WindSoilder@outlook.com>
This commit is contained in:
Hofer-Julian 2023-09-18 07:49:26 +02:00 committed by GitHub
parent bc7736bc99
commit f0a265dbee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 10 deletions

2
Cargo.lock generated
View File

@ -4293,7 +4293,7 @@ dependencies = [
[[package]]
name = "reedline"
version = "0.23.0"
source = "git+https://github.com/nushell/reedline.git?branch=main#31257a4c5413d4a262912359f515907b8295db5c"
source = "git+https://github.com/nushell/reedline.git?branch=main#f9939396905a81841645da30b411f3a255c7a037"
dependencies = [
"chrono",
"crossterm 0.27.0",

View File

@ -70,12 +70,14 @@ impl Command for History {
} else {
let history_reader: Option<Box<dyn ReedlineHistory>> =
match engine_state.config.history_file_format {
HistoryFileFormat::Sqlite => SqliteBackedHistory::with_file(history_path)
.map(|inner| {
let boxed: Box<dyn ReedlineHistory> = Box::new(inner);
boxed
})
.ok(),
HistoryFileFormat::Sqlite => {
SqliteBackedHistory::with_file(history_path, None, None)
.map(|inner| {
let boxed: Box<dyn ReedlineHistory> = Box::new(inner);
boxed
})
.ok()
}
HistoryFileFormat::PlainText => FileBackedHistory::with_file(
engine_state.config.max_history_size as usize,

View File

@ -730,9 +730,14 @@ fn update_line_editor_history(
)
.into_diagnostic()?,
),
HistoryFileFormat::Sqlite => {
Box::new(SqliteBackedHistory::with_file(history_path.to_path_buf()).into_diagnostic()?)
}
HistoryFileFormat::Sqlite => Box::new(
SqliteBackedHistory::with_file(
history_path.to_path_buf(),
history_session_id,
Some(chrono::Utc::now()),
)
.into_diagnostic()?,
),
};
let line_editor = line_editor
.with_history_session_id(history_session_id)