on master help sign in
editor: go to pos where stack pointer is located
1321983Dmitry Sharshakov
helix-term/src/application.rs+18−2
@@ -1,9 +1,16 @@
1−use helix_core::syntax;
1+use helix_core::{syntax, Selection};
2use helix_dap::Payload;
2use helix_dap::Payload;
3use helix_lsp::{lsp, util::lsp_pos_to_pos, LspProgressMap};
3use helix_lsp::{lsp, util::lsp_pos_to_pos, LspProgressMap};
4use helix_view::{theme, Editor};
4use helix_view::{theme, Editor};
5
5
6+use crate::{
7+ args::Args,
8+ commands::{align_view, Align},
6−use crate::{args::Args, compositor::Compositor, config::Config, job::Jobs, ui};
9+ compositor::Compositor,
10+ config::Config,
11+ job::Jobs,
12+ ui,
13+};
7
14
8use log::error;
15use log::error;
9
16
@@ -300,13 +307,22 @@ impl Application {
300 Some(helix_dap::Source {
307 Some(helix_dap::Source {
301 path: Some(src), ..
308 path: Some(src), ..
302 }),
309 }),
310+ line,
311+ column,
303 ..
312 ..
304 }) = &debugger.stack_pointer
313 }) = &debugger.stack_pointer
305 {
314 {
306 let path = src.clone();
315 let path = src.clone();
316+ let line = *line;
317+ let column = *column;
307 self.editor
318 self.editor
308 .open(path, helix_view::editor::Action::Replace)
319 .open(path, helix_view::editor::Action::Replace)
309 .unwrap();
320 .unwrap();
321+
322+ let (view, doc) = current!(self.editor);
323+ let pos = doc.text().line_to_char(line - 1) + column;
324+ doc.set_selection(view.id, Selection::point(pos));
325+ align_view(doc, view, Align::Center);
310 }
326 }
311 self.editor.set_status(status);
327 self.editor.set_status(status);
312 }
328 }
helix-term/src/commands.rs+2−2
@@ -98,13 +98,13 @@ impl<'a> Context<'a> {
98 }
98 }
99}
99}
100
100
101−enum Align {
101+pub enum Align {
102 Top,
102 Top,
103 Center,
103 Center,
104 Bottom,
104 Bottom,
105}
105}
106
106
107−fn align_view(doc: &Document, view: &mut View, align: Align) {
107+pub fn align_view(doc: &Document, view: &mut View, align: Align) {
108 let pos = doc
108 let pos = doc
109 .selection(view.id)
109 .selection(view.id)
110 .primary()
110 .primary()