aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands/dap.rs20
-rw-r--r--helix-term/src/ui/editor.rs48
2 files changed, 16 insertions, 52 deletions
diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs
index 566730e1..23bb3bab 100644
--- a/helix-term/src/commands/dap.rs
+++ b/helix-term/src/commands/dap.rs
@@ -3,7 +3,7 @@ use crate::{
commands,
compositor::Compositor,
job::Callback,
- ui::{FilePicker, Prompt, PromptEvent},
+ ui::{FilePicker, Picker, Prompt, PromptEvent},
};
use helix_core::{
syntax::{DebugArgumentValue, DebugConfigCompletion},
@@ -319,14 +319,16 @@ pub fn dap_launch(cx: &mut Context) {
}
};
- cx.editor.debug_config_picker = Some(config.templates.iter().map(|t| t.name.clone()).collect());
- cx.editor.debug_config_completions = Some(
- config
- .templates
- .iter()
- .map(|t| t.completion.clone())
- .collect(),
- );
+ cx.push_layer(Box::new(Picker::new(
+ true,
+ config.templates.clone(),
+ |template| template.name.as_str().into(),
+ |editor, template, _action| {
+ let completions = template.completion.clone();
+ editor.debug_config_completions = completions;
+ // TODO: need some way to manipulate the compositor to push a new prompt here
+ },
+ ))); // TODO: wrap in popup with fixed size
}
pub fn dap_toggle_breakpoint(cx: &mut Context) {
diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs
index 26a0358d..706cf8bb 100644
--- a/helix-term/src/ui/editor.rs
+++ b/helix-term/src/ui/editor.rs
@@ -902,29 +902,11 @@ impl EditorView {
cxt: &mut commands::Context,
event: KeyEvent,
) -> Option<KeymapResult> {
- if let Some(picker) = cxt.editor.debug_config_picker.clone() {
- match event {
- KeyEvent {
- code: KeyCode::Esc, ..
- } => {}
- KeyEvent {
- code: KeyCode::Char(char),
- ..
- } => {
- let (i, name) = match picker.iter().position(|t| t.starts_with(char)) {
- Some(pos) => (pos, picker.get(pos).unwrap().clone()),
- None => return None,
- };
- let completions = cxt.editor.debug_config_completions.clone().unwrap();
- let completion = completions.get(i).unwrap().clone();
- if !completion.is_empty() {
- let prompt = Self::debug_parameter_prompt(completion, name, Vec::new());
- cxt.push_layer(Box::new(prompt));
- }
- }
- _ => return None,
- }
- cxt.editor.debug_config_picker = None;
+ if !cxt.editor.debug_config_completions.is_empty() {
+ let completions = std::mem::take(&mut cxt.editor.debug_config_completions);
+ // TODO name
+ let prompt = Self::debug_parameter_prompt(completions, "test".to_string(), Vec::new());
+ cxt.push_layer(Box::new(prompt));
return None;
}
@@ -1429,26 +1411,6 @@ impl Component for EditorView {
info.render(area, surface, cx);
}
- if let Some(ref configs) = cx.editor.debug_config_picker {
- let mut text = String::new();
- let mut height = 0;
- let mut max_len = 20;
-
- for line in configs {
- max_len = max_len.max(line.len() as u16 + 2);
- height += 1;
- text.push_str(&format!("{} {}\n", line.chars().next().unwrap(), line));
- }
-
- let mut info = Info {
- height: 20.min(height + 1),
- width: 70.min(max_len),
- title: "Debug targets".to_owned(),
- text: text + "Exit Esc",
- };
- info.render(area, surface, cx);
- }
-
if cx.editor.config.auto_info {
if let Some(ref mut info) = self.autoinfo {
info.render(area, surface, cx);