@@ -30,6 +30,8 @@ use std::borrow::Cow;
3030use crossterm::event::{Event, MouseButton, MouseEvent, MouseEventKind};
3131use tui::buffer::Buffer as Surface;
3232
33+use super::{Prompt, PromptEvent};
34+
3335pub struct EditorView {
3436 keymaps: Keymaps,
3537 on_next_key: Option<Box<dyn FnOnce(&mut commands::Context, KeyEvent)>>,
@@ -712,6 +714,45 @@ impl EditorView {
712714 ) -> Option<KeymapResult> {
713715 self.autoinfo = None;
714716
717+ if let Some(picker) = cxt.editor.debug_config_picker.clone() {
718+ match event {
719+ KeyEvent {
720+ code: KeyCode::Esc, ..
721+ } => {}
722+ KeyEvent {
723+ code: KeyCode::Char(char),
724+ ..
725+ } => {
726+ let name = match picker.iter().find(|t| t.starts_with(char)) {
727+ Some(n) => n.clone(),
728+ None => return None,
729+ };
730+ let prompt = Prompt::new(
731+ "arg:".to_owned(),
732+ None,
733+ |_input: &str| Vec::new(), // this is fine because Vec::new() doesn't allocate
734+ move |cx: &mut crate::compositor::Context,
735+ input: &str,
736+ event: PromptEvent| {
737+ if event != PromptEvent::Validate {
738+ return;
739+ }
740+ commands::dap_start_impl(
741+ cx.editor,
742+ Some(&name),
743+ None,
744+ Some(vec![input]),
745+ );
746+ },
747+ );
748+ cxt.push_layer(Box::new(prompt));
749+ }
750+ _ => return None,
751+ }
752+ cxt.editor.debug_config_picker = None;
753+ return None;
754+ }
755+
715756 if cxt.editor.variables.is_some() {
716757 match event {
717758 KeyEvent {
@@ -735,6 +776,7 @@ impl EditorView {
735776 }
736777 return None;
737778 }
779+
738780 match self.keymaps.get_mut(&mode).unwrap().get(event) {
739781 KeymapResult::Matched(command) => command.execute(cxt),
740782 KeymapResult::Pending(node) => self.autoinfo = Some(node.into()),
@@ -1137,6 +1179,26 @@ impl Component for EditorView {
11371179 info.render(area, surface, cx);
11381180 }
11391181
1182+ if let Some(ref configs) = cx.editor.debug_config_picker {
1183+ let mut text = String::new();
1184+ let mut height = 0;
1185+ let mut max_len = 20;
1186+
1187+ for line in configs {
1188+ max_len = max_len.max(line.len() as u16 + 2);
1189+ height += 1;
1190+ text.push_str(&format!("{} {}\n", line.chars().next().unwrap(), line));
1191+ }
1192+
1193+ let mut info = Info {
1194+ height: 20.min(height + 1),
1195+ width: 70.min(max_len),
1196+ title: "Debug targets".to_owned(),
1197+ text: text + "Exit Esc",
1198+ };
1199+ info.render(area, surface, cx);
1200+ }
1201+
11401202 if let Some(ref mut info) = self.autoinfo {
11411203 info.render(area, surface, cx);
11421204 }