@@ -239,7 +239,7 @@ impl Renderer {
239239
240240 pub fn render_prompt(&mut self, view: &View, prompt: &Prompt) {
241241 // completion
242− if let Some(completion) = &prompt.completion {
242+ if !prompt.completion.is_empty() {
243243 // TODO: find out better way of clearing individual lines of the screen
244244 for i in (3..7) {
245245 self.surface.set_string(
@@ -255,10 +255,10 @@ impl Renderer {
255255 );
256256 let mut row = 0;
257257 let mut col = 0;
258− let max_row: u16 = self.size.0 / BASE_WIDTH;
258+ let max_col: u16 = self.size.0 / BASE_WIDTH;
259259 // TODO: this will crash if there are too many cols added
260260 // TODO: set char limit
261− for (i, command) in completion.iter().enumerate() {
261+ for (i, command) in prompt.completion.iter().enumerate() {
262262 let color = if prompt.completion_selection_index.is_some()
263263 && i == prompt.completion_selection_index.unwrap()
264264 {
@@ -267,18 +267,18 @@ impl Renderer {
267267 self.text_color
268268 };
269269 self.surface.set_stringn(
270− 1 + row * BASE_WIDTH,
271− self.size.1 - 6 + col as u16,
270+ 1 + col * BASE_WIDTH,
271+ self.size.1 - 6 + row as u16,
272272 &command,
273273 BASE_WIDTH as usize - 1,
274274 color,
275275 );
276− col += 1;
277− if col > 3 {
278− col = 0;
279− row += 1;
276+ row += 1;
277+ if row > 3 {
278+ row = 0;
279+ col += 1;
280280 }
281− if row > max_row {
281+ if col > max_col {
282282 break;
283283 }
284284 }
@@ -434,7 +434,6 @@ impl Application {
434434 let prompt = Prompt::new(
435435 ":".to_owned(),
436436 |_input: &str| {
437− let mut matches = vec![];
438437 // TODO: i need this duplicate list right now to avoid borrow checker issues
439438 let command_list = vec![
440439 String::from("q"),
@@ -469,15 +468,10 @@ impl Application {
469468 String::from("ddd"),
470469 String::from("eee"),
471470 ];
472− for command in command_list {
473− if command.contains(_input) {
474− matches.push(command);
475− }
476− }
477− if matches.len() != 0 {
478− return Some(matches);
479− }
480− None
471+ command_list
472+ .into_iter()
473+ .filter(|command| command.contains(_input))
474+ .collect()
481475 }, // completion
482476 |editor: &mut Editor, input: &str| match input {
483477 "q" => editor.should_close = true,