diff options
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/src/commands/dap.rs | 11 | ||||
-rw-r--r-- | helix-term/src/ui/editor.rs | 64 |
2 files changed, 14 insertions, 61 deletions
diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs index 47e1b39f..e7f9c214 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, Picker, Prompt, PromptEvent}, + ui::{FilePicker, Picker, Popup, Prompt, PromptEvent, Text}, }; use helix_core::{ syntax::{DebugArgumentValue, DebugConfigCompletion}, @@ -518,15 +518,14 @@ pub fn dap_variables(cx: &mut Context) { Some(data_type) => format!("{} ", data_type), None => "".to_owned(), }; - variables.push(format!("{}{} = {}\n", prefix, var.name, var.value)); + variables.push(format!("{}{} = {}", prefix, var.name, var.value)); } } } - if !variables.is_empty() { - cx.editor.variables = Some(variables); - cx.editor.variables_page = 0; - } + let contents = Text::new(variables.join("\n")); + let popup = Popup::new(contents); + cx.push_layer(Box::new(popup)); } pub fn dap_terminate(cx: &mut Context) { diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 4947706a..4d143084 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -906,30 +906,6 @@ impl EditorView { return None; } - if cxt.editor.variables.is_some() { - match event { - KeyEvent { - code: KeyCode::Char('h'), - .. - } => { - cxt.editor.variables_page = cxt.editor.variables_page.saturating_sub(1); - } - KeyEvent { - code: KeyCode::Char('l'), - .. - } => { - cxt.editor.variables_page = cxt.editor.variables_page.saturating_add(1); - } - KeyEvent { - code: KeyCode::Esc, .. - } => { - cxt.editor.variables = None; - } - _ => {} - } - return None; - } - let key_result = self.keymaps.get_mut(&mode).unwrap().get(event); self.autoinfo = key_result.sticky.map(|node| node.infobox()); @@ -1081,7 +1057,10 @@ impl EditorView { if let Some((line, _, view_id)) = result { editor.tree.focus = view_id; - let doc = editor.documents.get_mut(&editor.tree.get(view_id).doc).unwrap(); + let doc = editor + .documents + .get_mut(&editor.tree.get(view_id).doc) + .unwrap(); if let Ok(pos) = doc.text().try_line_to_char(line) { doc.set_selection(view_id, Selection::point(pos)); commands::dap_toggle_breakpoint(cxt); @@ -1180,7 +1159,11 @@ impl EditorView { if let Some((line, _, view_id)) = result { cxt.editor.tree.focus = view_id; - let doc = cxt.editor.documents.get_mut(&cxt.editor.tree.get(view_id).doc).unwrap(); + let doc = cxt + .editor + .documents + .get_mut(&cxt.editor.tree.get(view_id).doc) + .unwrap(); if let Ok(pos) = doc.text().try_line_to_char(line) { doc.set_selection(view_id, Selection::point(pos)); if modifiers == crossterm::event::KeyModifiers::ALT { @@ -1378,35 +1361,6 @@ impl Component for EditorView { ); } - if let Some(ref vars) = cx.editor.variables { - let mut text = String::new(); - let mut height = 0; - let mut max_len = 20; - - let per_page = 15; - let num_vars = vars.len(); - let start = (per_page * cx.editor.variables_page).min(num_vars); - let end = (start + per_page).min(num_vars); - for line in vars[start..end].to_vec() { - max_len = max_len.max(line.len() as u16); - height += 1; - text.push_str(&line); - } - - if vars.len() > per_page { - text += "\nMove h, l"; - height += 1; - } - - let mut info = Info { - height: 20.min(height + 2), - width: 70.min(max_len), - title: format!("{} variables", num_vars), - text: text + "\nExit 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); |