Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
target/
history.txt
history.sqlite3
.DS_Store
target-coverage/
tarpaulin-report.html
Expand Down
133 changes: 133 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ strip-ansi-escapes = "0.1.1"
strum = "0.24"
strum_macros = "0.24"
fd-lock = "3.0.3"
rusqlite = { version = "0.27.0", optional = true, features = ["bundled"] }
serde_json = { version = "1.0.79", optional = true }

[dev-dependencies]
tempfile = "3.3.0"
Expand All @@ -36,3 +38,4 @@ rstest = "0.12.0"
[features]
system_clipboard = ["clipboard"]
bashisms = []
sqlite = ["rusqlite", "serde_json"]
1 change: 0 additions & 1 deletion src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ impl Reedline {
let history: Vec<_> = self
.history
.iter_chronologic()
.cloned()
.enumerate()
.collect();

Expand Down
3 changes: 1 addition & 2 deletions src/history/base.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::core_editor::LineBuffer;
use std::collections::vec_deque::Iter;

/// Browsing modes for a [`History`]
#[derive(Debug, Clone, PartialEq, Eq)]
Expand All @@ -20,7 +19,7 @@ pub trait History: Send {
fn append(&mut self, entry: &str);

/// Chronologic interaction over all entries present in the history
fn iter_chronologic(&self) -> Iter<'_, String>;
fn iter_chronologic(&self) -> Box<dyn DoubleEndedIterator<Item=String> + '_>;

/// This moves the cursor backwards respecting the navigation query that is set
/// - Results in a no-op if the cursor is at the initial point
Expand Down
5 changes: 2 additions & 3 deletions src/history/file_backed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ impl History for FileBackedHistory {
self.reset_cursor();
}

fn iter_chronologic(&self) -> Iter<'_, String> {
self.entries.iter()
fn iter_chronologic(&self) -> Box<(dyn DoubleEndedIterator<Item = String> + '_)> {
Box::new(self.entries.iter().map(|e| e.to_string()))
}

fn back(&mut self) {
Expand Down Expand Up @@ -121,7 +121,6 @@ impl History for FileBackedHistory {
self.iter_chronologic()
.rev()
.filter(|entry| entry.contains(search))
.cloned()
.collect::<Vec<String>>()
}

Expand Down
6 changes: 5 additions & 1 deletion src/history/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
mod base;
mod file_backed;
#[cfg(feature="sqlite")]
mod sqlite_backed;
#[cfg(feature="sqlite")]
pub use sqlite_backed::SqliteBackedHistory;

pub use base::{History, HistoryNavigationQuery};
pub use file_backed::{FileBackedHistory, HISTORY_SIZE};
pub use file_backed::{FileBackedHistory, HISTORY_SIZE};
Loading