Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4f71b89
basic sqlite history
phiresky Apr 1, 2022
dd93aba
fix test compilation
phiresky Apr 1, 2022
4c03e68
final touches for MVP
phiresky Apr 1, 2022
a669fb3
better documentation
phiresky Apr 1, 2022
187f867
fix for empty history
phiresky Apr 2, 2022
01b62e7
partial change to non-generic history
phiresky Apr 16, 2022
3e76ae7
mostly working
phiresky Apr 16, 2022
317a69f
fix tests and ci
phiresky Apr 18, 2022
7d4b7ca
fixes, format
phiresky Apr 18, 2022
5fc904e
move history item to new file
phiresky Apr 18, 2022
f756189
fix some comments, fix test compile errors
phiresky Apr 20, 2022
4d60705
ci features matrix
phiresky Apr 20, 2022
13b32b9
fix index creation
phiresky Apr 18, 2022
56a210c
fix file-based tests
phiresky May 8, 2022
7c6b09a
move logic for not saving empty entries to engine
phiresky May 8, 2022
9cab40f
fix update last command on empty, set up application_id and check ver…
phiresky May 8, 2022
37afda0
Merge remote-tracking branch 'origin/main' into sqlite-history-2
phiresky May 8, 2022
556115b
add specific error variants
phiresky May 8, 2022
285ea4b
format
phiresky May 11, 2022
c772fad
fix compile errors
phiresky May 11, 2022
74c8f71
fix fmt
fdncred May 11, 2022
d84fd86
sqlite with bashisms
elferherrera May 21, 2022
a9c9d3a
Merge branch 'main' of https://github.com/nushell/reedline into sqlit…
elferherrera May 21, 2022
428544d
hide with features
elferherrera May 21, 2022
014bd48
cargo fmt
elferherrera May 21, 2022
a8d8703
improve performance of bashisms selectors
phiresky Jun 6, 2022
33b7610
Merge remote-tracking branch 'origin/main' into sqlite-history-2
phiresky Jun 6, 2022
6d803bb
Style: Remove commented out code
sholderbach Jun 6, 2022
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
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ jobs:
rust:
- stable
# Define the feature sets that will be built here (for caching you define a separate name)
style: [bashisms, default]
style: [bashisms, default, sqlite, basqlite]
include:
- style: bashisms
flags: "--features bashisms"
- style: default
flags: ""
- style: sqlite
flags: "--features sqlite"
- style: basqlite
flags: "--features bashisms,sqlite"

runs-on: ${{ matrix.platform }}

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
target/
history.txt
history.sqlite3*
.DS_Store
target-coverage/
tarpaulin-report.html
.vscode
.helix
165 changes: 165 additions & 0 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ 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 }
gethostname = { version = "0.2.3", optional = true }
thiserror = "1.0.31"

[dev-dependencies]
tempfile = "3.3.0"
Expand All @@ -36,4 +40,5 @@ rstest = "0.12.0"
[features]
system_clipboard = ["clipboard"]
bashisms = []
sqlite = ["rusqlite", "serde_json", "gethostname"]

41 changes: 21 additions & 20 deletions src/completion/history.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use std::ops::Deref;

use crate::{menu_functions::parse_selection_char, Completer, History, Span, Suggestion};
use crate::{
history::SearchQuery, menu_functions::parse_selection_char, Completer, History, Span,
Suggestion,
};

const SELECTION_CHAR: char = '!';

Expand All @@ -15,32 +18,30 @@ unsafe impl<'menu> Send for HistoryCompleter<'menu> {}
impl<'menu> Completer for HistoryCompleter<'menu> {
fn complete(&mut self, line: &str, pos: usize) -> Vec<Suggestion> {
let parsed = parse_selection_char(line, SELECTION_CHAR);
let values = self.0.query_entries(parsed.remainder);
let values = self
.0
.search(SearchQuery::all_that_contain_rev(
parsed.remainder.to_string(),
))
.expect("todo: error handling");

values
.into_iter()
.map(|value| self.create_suggestion(line, pos, value.deref()))
.map(|value| self.create_suggestion(line, pos, value.command_line.deref()))
.collect()
}

fn partial_complete(
&mut self,
line: &str,
pos: usize,
start: usize,
offset: usize,
) -> Vec<Suggestion> {
self.0
.iter_chronologic()
.rev()
.skip(start)
.take(offset)
.map(|value| self.create_suggestion(line, pos, value.deref()))
.collect()
}
// TODO: Implement `fn partial_complete()`

fn total_completions(&mut self, _line: &str, _pos: usize) -> usize {
self.0.max_values()
fn total_completions(&mut self, line: &str, _pos: usize) -> usize {
let parsed = parse_selection_char(line, SELECTION_CHAR);
let count = self
.0
.count(SearchQuery::all_that_contain_rev(
parsed.remainder.to_string(),
))
.expect("todo: error handling");
count as usize
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/core_editor/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ impl Default for Editor {
}

impl Editor {
pub fn line_buffer_immut(&self) -> &LineBuffer {
&self.line_buffer
}
pub fn line_buffer(&mut self) -> &mut LineBuffer {
&mut self.line_buffer
}
Expand Down
Loading