diff options
author | Dmitry Sharshakov | 2021-08-22 08:56:22 +0000 |
---|---|---|
committer | Dmitry Sharshakov | 2021-08-22 08:56:22 +0000 |
commit | 132198323ca8af409ecac56e14f8029c9d252621 (patch) | |
tree | 92b6cec5034d9a02ff21b01efd57c750b680850b | |
parent | be9dc5802a8e2d6d26d6f9c00475aedafef97c61 (diff) |
editor: go to pos where stack pointer is located
-rw-r--r-- | helix-term/src/application.rs | 20 | ||||
-rw-r--r-- | helix-term/src/commands.rs | 4 |
2 files changed, 20 insertions, 4 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 9f0e751e..0d10c9b5 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -1,9 +1,16 @@ -use helix_core::syntax; +use helix_core::{syntax, Selection}; use helix_dap::Payload; use helix_lsp::{lsp, util::lsp_pos_to_pos, LspProgressMap}; use helix_view::{theme, Editor}; -use crate::{args::Args, compositor::Compositor, config::Config, job::Jobs, ui}; +use crate::{ + args::Args, + commands::{align_view, Align}, + compositor::Compositor, + config::Config, + job::Jobs, + ui, +}; use log::error; @@ -300,13 +307,22 @@ impl Application { Some(helix_dap::Source { path: Some(src), .. }), + line, + column, .. }) = &debugger.stack_pointer { let path = src.clone(); + let line = *line; + let column = *column; self.editor .open(path, helix_view::editor::Action::Replace) .unwrap(); + + let (view, doc) = current!(self.editor); + let pos = doc.text().line_to_char(line - 1) + column; + doc.set_selection(view.id, Selection::point(pos)); + align_view(doc, view, Align::Center); } self.editor.set_status(status); } diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index cc45f79a..d405de16 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -98,13 +98,13 @@ impl<'a> Context<'a> { } } -enum Align { +pub enum Align { Top, Center, Bottom, } -fn align_view(doc: &Document, view: &mut View, align: Align) { +pub fn align_view(doc: &Document, view: &mut View, align: Align) { let pos = doc .selection(view.id) .primary() |