Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch(preprocessor): update ::commit #199

Merged
merged 1 commit into from
Mar 21, 2024
Merged
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
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
Loading