@@ -1,6 +1,5 @@
1use super::{align_view, Align, Context, Editor};
1use super::{align_view, Align, Context, Editor};
2use crate::{
2use crate::{
4 compositor::Compositor,
3 compositor::Compositor,
5 job::Callback,
4 job::Callback,
6 ui::{self, FilePicker, Picker, Popup, Prompt, PromptEvent, Text},
5 ui::{self, FilePicker, Picker, Popup, Prompt, PromptEvent, Text},
@@ -161,6 +160,22 @@ fn thread_picker(cx: &mut Context, callback_fn: impl Fn(&mut Editor, &dap::Threa
161 cx.push_layer(Box::new(picker))
160 cx.push_layer(Box::new(picker))
163+fn get_breakpoint_at_current_line(editor: &mut Editor) -> Option<(usize, Breakpoint)> {
164+ let (view, doc) = current!(editor);
165+ let text = doc.text().slice(..);
167+ let pos = doc.selection(view.id).primary().cursor(text);
168+ let line = text.char_to_line(pos);
169+ let path = match doc.path() {
171+ None => return None,
173+ editor.breakpoints.get(path).and_then(|breakpoints| {
174+ let i = breakpoints.iter().position(|b| b.line == line);
175+ i.map(|i| (i, breakpoints[i].clone()))
166pub fn dap_start_impl(
181pub fn dap_start_impl(
@@ -381,7 +396,7 @@ fn debug_parameter_prompt(
382 cx.jobs.callback(callback);
397 cx.jobs.callback(callback);
384− commands::dap_start_impl(
399+ dap_start_impl(
385 cx.editor,
400 cx.editor,
386 Some(&config_name),
401 Some(&config_name),
@@ -679,7 +694,7 @@ pub fn dap_disable_exceptions(cx: &mut Context) {
680// TODO: both edit condition and edit log need to be stable: we might get new breakpoints from the debugger which can change offsets
695// TODO: both edit condition and edit log need to be stable: we might get new breakpoints from the debugger which can change offsets
681pub fn dap_edit_condition(cx: &mut Context) {
696pub fn dap_edit_condition(cx: &mut Context) {
682− if let Some((pos, breakpoint)) = commands::cmd::get_breakpoint_at_current_line(cx.editor) {
697+ if let Some((pos, breakpoint)) = get_breakpoint_at_current_line(cx.editor) {
683 let path = match doc!(cx.editor).path() {
698 let path = match doc!(cx.editor).path() {
684 Some(path) => path.clone(),
699 Some(path) => path.clone(),
685 None => return,
700 None => return,
@@ -726,7 +741,7 @@ pub fn dap_edit_condition(cx: &mut Context) {
728pub fn dap_edit_log(cx: &mut Context) {
743pub fn dap_edit_log(cx: &mut Context) {
729− if let Some((pos, breakpoint)) = commands::cmd::get_breakpoint_at_current_line(cx.editor) {
744+ if let Some((pos, breakpoint)) = get_breakpoint_at_current_line(cx.editor) {
730 let path = match doc!(cx.editor).path() {
745 let path = match doc!(cx.editor).path() {
731 Some(path) => path.clone(),
746 Some(path) => path.clone(),
732 None => return,
747 None => return,