@@ -239,7 +239,7 @@ impl Renderer {
240 pub fn render_prompt(&mut self, view: &View, prompt: &Prompt) {
240 pub fn render_prompt(&mut self, view: &View, prompt: &Prompt) {
241 // completion
241 // completion
242− if let Some(completion) = &prompt.completion {
242+ if !prompt.completion.is_empty() {
243 // TODO: find out better way of clearing individual lines of the screen
243 // TODO: find out better way of clearing individual lines of the screen
244 for i in (3..7) {
244 for i in (3..7) {
245 self.surface.set_string(
245 self.surface.set_string(
@@ -255,10 +255,10 @@ impl Renderer {
256 let mut row = 0;
256 let mut row = 0;
257 let mut col = 0;
257 let mut col = 0;
258− let max_row: u16 = self.size.0 / BASE_WIDTH;
258+ let max_col: u16 = self.size.0 / BASE_WIDTH;
259 // TODO: this will crash if there are too many cols added
259 // TODO: this will crash if there are too many cols added
260 // TODO: set char limit
260 // TODO: set char limit
261− for (i, command) in completion.iter().enumerate() {
261+ for (i, command) in prompt.completion.iter().enumerate() {
262 let color = if prompt.completion_selection_index.is_some()
262 let color = if prompt.completion_selection_index.is_some()
263 && i == prompt.completion_selection_index.unwrap()
263 && i == prompt.completion_selection_index.unwrap()
@@ -267,18 +267,18 @@ impl Renderer {
267 self.text_color
267 self.text_color
269 self.surface.set_stringn(
269 self.surface.set_stringn(
270− 1 + row * BASE_WIDTH,
270+ 1 + col * BASE_WIDTH,
271− self.size.1 - 6 + col as u16,
271+ self.size.1 - 6 + row as u16,
272 &command,
272 &command,
273 BASE_WIDTH as usize - 1,
273 BASE_WIDTH as usize - 1,
276− col += 1;
276+ row += 1;
277− if col > 3 {
277+ if row > 3 {
278− col = 0;
278+ row = 0;
279− row += 1;
279+ col += 1;
281− if row > max_row {
281+ if col > max_col {
@@ -434,7 +434,6 @@ impl Application {
434 let prompt = Prompt::new(
434 let prompt = Prompt::new(
435 ":".to_owned(),
435 ":".to_owned(),
436 |_input: &str| {
436 |_input: &str| {
437− let mut matches = vec![];
438 // TODO: i need this duplicate list right now to avoid borrow checker issues
437 // TODO: i need this duplicate list right now to avoid borrow checker issues
439 let command_list = vec![
438 let command_list = vec![
440 String::from("q"),
439 String::from("q"),
@@ -469,15 +468,10 @@ impl Application {
469 String::from("ddd"),
468 String::from("ddd"),
470 String::from("eee"),
469 String::from("eee"),
472− for command in command_list {
471+ command_list
473− if command.contains(_input) {
473+ .filter(|command| command.contains(_input))
474− matches.push(command);
474+ .collect()
477− if matches.len() != 0 {
478− return Some(matches);
481 }, // completion
475 }, // completion
482 |editor: &mut Editor, input: &str| match input {
476 |editor: &mut Editor, input: &str| match input {
483 "q" => editor.should_close = true,
477 "q" => editor.should_close = true,