@@ -15,6 +15,7 @@ use helix_core::{
15 unicode::width::UnicodeWidthStr,
15 unicode::width::UnicodeWidthStr,
16 LineEnding, Position, Range, Selection,
16 LineEnding, Position, Range, Selection,
18+use helix_dap::{SourceBreakpoint, StackFrame};
18use helix_view::{
19use helix_view::{
19 document::Mode,
20 document::Mode,
20 editor::LineNumber,
21 editor::LineNumber,
@@ -24,7 +25,8 @@ use helix_view::{
24 keyboard::{KeyCode, KeyModifiers},
25 keyboard::{KeyCode, KeyModifiers},
25 Document, Editor, Theme, View,
26 Document, Editor, Theme, View,
27−use std::borrow::Cow;
28+use std::{borrow::Cow, sync::Arc};
29+use tokio::sync::Mutex;
29use crossterm::event::{Event, MouseButton, MouseEvent, MouseEventKind};
31use crossterm::event::{Event, MouseButton, MouseEvent, MouseEventKind};
30use tui::buffer::Buffer as Surface;
32use tui::buffer::Buffer as Surface;
@@ -71,7 +73,7 @@ impl EditorView {
71 is_focused: bool,
73 is_focused: bool,
72 loader: &syntax::Loader,
74 loader: &syntax::Loader,
73 config: &helix_view::editor::Config,
75 config: &helix_view::editor::Config,
74− debugger: Option<&helix_dap::Client>,
76+ debugger: Option<Arc<Mutex<helix_dap::Client>>>,
76 let inner = view.inner_area();
78 let inner = view.inner_area();
77 let area = view.area;
79 let area = view.area;
@@ -412,8 +414,9 @@ impl EditorView {
412 theme: &Theme,
414 theme: &Theme,
413 is_focused: bool,
415 is_focused: bool,
414 config: &helix_view::editor::Config,
416 config: &helix_view::editor::Config,
415− debugger: Option<&helix_dap::Client>,
417+ debugger: Option<Arc<Mutex<helix_dap::Client>>>,
419+ use helix_lsp::block_on;
417 let text = doc.text().slice(..);
420 let text = doc.text().slice(..);
418 let last_line = view.last_line(doc);
421 let last_line = view.last_line(doc);
@@ -442,9 +445,15 @@ impl EditorView {
442 .map(|range| range.cursor_line(text))
445 .map(|range| range.cursor_line(text))
443 .collect();
446 .collect();
445− let breakpoints = doc
448+ let mut breakpoints: Option<Vec<SourceBreakpoint>> = None;
446− .path()
449+ let mut stack_pointer: Option<StackFrame> = None;
447− .and_then(|path| debugger.and_then(|debugger| debugger.breakpoints.get(path)));
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()
449 for (i, line) in (view.offset.row..(last_line + 1)).enumerate() {
458 for (i, line) in (view.offset.row..(last_line + 1)).enumerate() {
450 use helix_core::diagnostic::Severity;
459 use helix_core::diagnostic::Severity;
@@ -465,12 +474,23 @@ impl EditorView {
466 let selected = cursors.contains(&line);
475 let selected = cursors.contains(&line);
468− if let Some(_breakpoint) = breakpoints.and_then(|breakpoints| {
477+ if let Some(bps) = breakpoints.as_ref() {
471− .find(|breakpoint| breakpoint.line == line)
478+ if let Some(_) = bps.iter().find(|breakpoint| breakpoint.line == line) {
473− surface.set_stringn(viewport.x, viewport.y + i as u16, "▲", 1, warning);
479+ surface.set_stringn(viewport.x, viewport.y + i as u16, "▲", 1, warning);
483+ if let Some(sp) = stack_pointer.as_ref() {
484+ if let Some(src) = sp.source.as_ref() {
487+ .and_then(|path| Some(src.path == Some(path.clone())))
491+ surface.set_stringn(viewport.x, viewport.y + i as u16, "⇒", 1, warning);
476 let text = if line == last_line && !draw_last {
496 let text = if line == last_line && !draw_last {
@@ -1023,7 +1043,10 @@ impl Component for EditorView {
1023 for (view, is_focused) in cx.editor.tree.views() {
1043 for (view, is_focused) in cx.editor.tree.views() {
1024 let doc = cx.editor.document(view.doc).unwrap();
1044 let doc = cx.editor.document(view.doc).unwrap();
1025 let loader = &cx.editor.syn_loader;
1045 let loader = &cx.editor.syn_loader;
1046+ let mut dbg: Option<Arc<Mutex<helix_dap::Client>>> = None;
1026− let debugger = cx.editor.debugger.as_ref();
1047+ if let Some(debugger) = &cx.editor.debugger {
1048+ dbg = Some(Arc::clone(&debugger));
1027 self.render_view(
1050 self.render_view(
@@ -1033,7 +1056,7 @@ impl Component for EditorView {
1033 is_focused,
1056 is_focused,
1035 &cx.editor.config,
1058 &cx.editor.config,
1036− debugger,
1059+ dbg,