Skip to content

Commit

Permalink
patch(preprocessor): update ::commit (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonbrad committed Mar 21, 2024
1 parent 17bc7bb commit 5cde042
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions engine/preprocessor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ impl Preprocessor {
/// ..Default::default()
/// });
///
/// preprocessor.commit("sī");
/// preprocessor.commit("sī".to_owned());
///
/// // The generated commands.
/// // The expected results without inhibit feature.
Expand Down Expand Up @@ -359,7 +359,7 @@ impl Preprocessor {
/// assert_eq!(command, expecteds.pop_front().unwrap());
/// }
/// ```
pub fn commit(&mut self, text: &str) {
pub fn commit(&mut self, text: String) {
self.pause();

while !self.cursor.is_empty() {
Expand All @@ -370,7 +370,7 @@ impl Preprocessor {
}
#[cfg(feature = "inhibit")]
self.cursor.clear();
self.queue.push_back(Command::CommitText(text.to_owned()));
self.queue.push_back(Command::CommitText(text));
self.resume();
// We clear the buffer
self.cursor.clear();
Expand Down Expand Up @@ -443,7 +443,7 @@ impl Preprocessor {
/// let memory = Rc::new(text_buffer);
///
/// let mut preprocessor = Preprocessor::new(memory, 8);
/// preprocessor.commit("hello");
/// preprocessor.commit("hello".to_owned());
///
/// // The expected results.
/// let mut expecteds = VecDeque::from(vec![
Expand Down Expand Up @@ -474,7 +474,7 @@ impl Preprocessor {
/// let memory = Rc::new(text_buffer);
///
/// let mut preprocessor = Preprocessor::new(memory, 8);
/// preprocessor.commit("hi");
/// preprocessor.commit("hi".to_owned());
/// preprocessor.clear_queue();
///
/// assert_eq!(preprocessor.pop_queue(), None);
Expand Down Expand Up @@ -552,7 +552,7 @@ mod tests {
key: Character("a".to_owned()),
..Default::default()
});
preprocessor.commit("word");
preprocessor.commit("word".to_owned());

let mut expecteds = VecDeque::from(vec![
Command::Pause,
Expand Down
4 changes: 2 additions & 2 deletions service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub fn run(config: Config, mut frontend: impl Frontend) -> Result<(), Box<dyn er
is_special_pressed = false;

if let Some((_code, _remaining_code, text)) = frontend.get_selected_predicate() {
preprocessor.commit(text);
preprocessor.commit(text.to_owned());
frontend.clear_predicates();
}
}
Expand All @@ -121,7 +121,7 @@ pub fn run(config: Config, mut frontend: impl Frontend) -> Result<(), Box<dyn er
.for_each(|(code, remaining_code, texts, translated)| {
texts.iter().for_each(|text| {
if auto_commit && *translated {
preprocessor.commit(text);
preprocessor.commit(text.to_owned());
} else if !text.is_empty() {
frontend.add_predicate(code, remaining_code, text);
}
Expand Down

0 comments on commit 5cde042

Please sign in to comment.