@@ -15,6 +15,7 @@ use helix_core::{
1515 unicode::width::UnicodeWidthStr,
1616 LineEnding, Position, Range, Selection,
1717};
18+use helix_dap::{SourceBreakpoint, StackFrame};
1819use helix_view::{
1920 document::Mode,
2021 editor::LineNumber,
@@ -24,7 +25,8 @@ use helix_view::{
2425 keyboard::{KeyCode, KeyModifiers},
2526 Document, Editor, Theme, View,
2627};
27−use std::borrow::Cow;
28+use std::{borrow::Cow, sync::Arc};
29+use tokio::sync::Mutex;
2830
2931use crossterm::event::{Event, MouseButton, MouseEvent, MouseEventKind};
3032use tui::buffer::Buffer as Surface;
@@ -71,7 +73,7 @@ impl EditorView {
7173 is_focused: bool,
7274 loader: &syntax::Loader,
7375 config: &helix_view::editor::Config,
74− debugger: Option<&helix_dap::Client>,
76+ debugger: Option<Arc<Mutex<helix_dap::Client>>>,
7577 ) {
7678 let inner = view.inner_area();
7779 let area = view.area;
@@ -412,8 +414,9 @@ impl EditorView {
412414 theme: &Theme,
413415 is_focused: bool,
414416 config: &helix_view::editor::Config,
415− debugger: Option<&helix_dap::Client>,
417+ debugger: Option<Arc<Mutex<helix_dap::Client>>>,
416418 ) {
419+ use helix_lsp::block_on;
417420 let text = doc.text().slice(..);
418421 let last_line = view.last_line(doc);
419422
@@ -442,9 +445,15 @@ impl EditorView {
442445 .map(|range| range.cursor_line(text))
443446 .collect();
444447
445− let breakpoints = doc
446− .path()
447− .and_then(|path| debugger.and_then(|debugger| debugger.breakpoints.get(path)));
448+ let mut breakpoints: Option<Vec<SourceBreakpoint>> = None;
449+ let mut stack_pointer: Option<StackFrame> = None;
450+ if let Some(debugger) = debugger {
451+ if let Some(path) = doc.path() {
452+ let dbg = block_on(debugger.lock());
453+ breakpoints = dbg.breakpoints.get(path).and_then(|bps| Some(bps.clone()));
454+ stack_pointer = dbg.stack_pointer.clone()
455+ }
456+ }
448457
449458 for (i, line) in (view.offset.row..(last_line + 1)).enumerate() {
450459 use helix_core::diagnostic::Severity;
@@ -465,12 +474,23 @@ impl EditorView {
465474
466475 let selected = cursors.contains(&line);
467476
468− if let Some(_breakpoint) = breakpoints.and_then(|breakpoints| {
469− breakpoints
470− .iter()
471− .find(|breakpoint| breakpoint.line == line)
472− }) {
473− surface.set_stringn(viewport.x, viewport.y + i as u16, "▲", 1, warning);
477+ if let Some(bps) = breakpoints.as_ref() {
478+ if let Some(_) = bps.iter().find(|breakpoint| breakpoint.line == line) {
479+ surface.set_stringn(viewport.x, viewport.y + i as u16, "▲", 1, warning);
480+ }
481+ }
482+
483+ if let Some(sp) = stack_pointer.as_ref() {
484+ if let Some(src) = sp.source.as_ref() {
485+ if doc
486+ .path()
487+ .and_then(|path| Some(src.path == Some(path.clone())))
488+ .unwrap_or(false)
489+ && sp.line == line
490+ {
491+ surface.set_stringn(viewport.x, viewport.y + i as u16, "⇒", 1, warning);
492+ }
493+ }
474494 }
475495
476496 let text = if line == last_line && !draw_last {
@@ -1023,7 +1043,10 @@ impl Component for EditorView {
10231043 for (view, is_focused) in cx.editor.tree.views() {
10241044 let doc = cx.editor.document(view.doc).unwrap();
10251045 let loader = &cx.editor.syn_loader;
1026− let debugger = cx.editor.debugger.as_ref();
1046+ let mut dbg: Option<Arc<Mutex<helix_dap::Client>>> = None;
1047+ if let Some(debugger) = &cx.editor.debugger {
1048+ dbg = Some(Arc::clone(&debugger));
1049+ }
10271050 self.render_view(
10281051 doc,
10291052 view,
@@ -1033,7 +1056,7 @@ impl Component for EditorView {
10331056 is_focused,
10341057 loader,
10351058 &cx.editor.config,
1036− debugger,
1059+ dbg,
10371060 );
10381061 }
10391062