@@ -34,6 +34,8 @@ type Terminal = tui::Terminal<CrosstermBackend<std::io::Stdout>>;
3434
3535static EX: smol::Executor = smol::Executor::new();
3636
37+const BASE_WIDTH: u16 = 30;
38+
3739pub struct Application {
3840 editor: Editor,
3941 prompt: Option<Prompt>,
@@ -253,9 +255,10 @@ impl Renderer {
253255 );
254256 let mut row = 0;
255257 let mut col = 0;
258+ let max_row: u16 = self.size.0 / BASE_WIDTH;
256259 // TODO: this will crash if there are too many cols added
257260 // TODO: set char limit
258− for i in (0..completion.len()) {
261+ for (i, command) in completion.iter().enumerate() {
259262 let color = if prompt.completion_selection_index.is_some()
260263 && i == prompt.completion_selection_index.unwrap()
261264 {
@@ -263,16 +266,20 @@ impl Renderer {
263266 } else {
264267 self.text_color
265268 };
266− self.surface.set_string(
267− 1 + col * 10,
268− self.size.1 - 6 + row as u16,
269− &completion[i],
269+ self.surface.set_stringn(
270+ 1 + row * BASE_WIDTH,
271+ self.size.1 - 6 + col as u16,
272+ &command,
273+ BASE_WIDTH as usize - 1,
270274 color,
271275 );
272− row += 1;
273− if row > 3 {
274− row = 0;
275− col += 1;
276+ col += 1;
277+ if col > 3 {
278+ col = 0;
279+ row += 1;
280+ }
281+ if row > max_row {
282+ break;
276283 }
277284 }
278285 }
@@ -436,6 +443,31 @@ impl Application {
436443 String::from("ccc"),
437444 String::from("ddd"),
438445 String::from("eee"),
446+ String::from("averylongcommandaverylongcommandaverylongcommandaverylongcommandaverylongcommand"),
447+ String::from("q"),
448+ String::from("aaa"),
449+ String::from("bbb"),
450+ String::from("ccc"),
451+ String::from("ddd"),
452+ String::from("eee"),
453+ String::from("q"),
454+ String::from("aaa"),
455+ String::from("bbb"),
456+ String::from("ccc"),
457+ String::from("ddd"),
458+ String::from("eee"),
459+ String::from("q"),
460+ String::from("aaa"),
461+ String::from("bbb"),
462+ String::from("ccc"),
463+ String::from("ddd"),
464+ String::from("eee"),
465+ String::from("q"),
466+ String::from("aaa"),
467+ String::from("bbb"),
468+ String::from("ccc"),
469+ String::from("ddd"),
470+ String::from("eee"),
439471 ];
440472 for command in command_list {
441473 if command.contains(_input) {