From b792d9a83d0ed5e71ba4c0ae62730db8fee00216 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 28 Feb 2022 23:02:46 -0500 Subject: push some copies up the stack --- src/shell/history/mod.rs | 10 +++++----- src/shell/mod.rs | 11 ++++++++--- src/shell/readline.rs | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) (limited to 'src/shell') diff --git a/src/shell/history/mod.rs b/src/shell/history/mod.rs index 5bcc820..8b67ed2 100644 --- a/src/shell/history/mod.rs +++ b/src/shell/history/mod.rs @@ -90,24 +90,24 @@ impl History { pub fn run( &mut self, - cmdline: &str, - env: &Env, + cmdline: String, + env: Env, event_w: crate::shell::event::Writer, ) -> usize { let (input_w, input_r) = tokio::sync::mpsc::unbounded_channel(); let (resize_w, resize_r) = tokio::sync::mpsc::unbounded_channel(); let entry = std::sync::Arc::new(std::sync::Mutex::new(Entry::new( - cmdline.to_string(), + cmdline.clone(), env.clone(), self.size, input_w, resize_w, ))); run_commands( - cmdline.to_string(), + cmdline, std::sync::Arc::clone(&entry), - env.clone(), + env, input_r, resize_r, event_w, diff --git a/src/shell/mod.rs b/src/shell/mod.rs index ab01161..a494752 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -417,7 +417,8 @@ impl Shell { entry.should_fullscreen(), ) }); - let idx = self.history.run(&input, &self.env, event_w); + let idx = + self.history.run(input, self.env.clone(), event_w); self.set_focus(Focus::History(idx), fullscreen); self.hide_readline = true; self.env.set_idx(idx + 1); @@ -469,7 +470,7 @@ impl Shell { let input = self .history .with_entry(idx, |entry| entry.cmd().to_string()); - self.readline.set_input(&input); + self.readline.set_input(input); self.set_focus(Focus::Readline, false); } } @@ -532,7 +533,11 @@ impl Shell { textmode::Key::Ctrl(b'm') => { let input = self.readline.input(); if !input.is_empty() { - let idx = self.history.run(input, &self.env, event_w); + let idx = self.history.run( + input.to_string(), + self.env.clone(), + event_w, + ); self.set_focus( Focus::History(idx), self.history.should_fullscreen(idx), diff --git a/src/shell/readline.rs b/src/shell/readline.rs index 49a3ab6..5de9901 100644 --- a/src/shell/readline.rs +++ b/src/shell/readline.rs @@ -102,9 +102,9 @@ impl Readline { self.inc_pos(s.chars().count()); } - pub fn set_input(&mut self, s: &str) { - self.input_line = s.to_string(); + pub fn set_input(&mut self, s: String) { self.set_pos(s.chars().count()); + self.input_line = s; } pub fn backspace(&mut self) { -- cgit v1.2.3-54-g00ecf