@@ -1924,42 +1924,30 @@ mod cmd {
1927− fn debug_breakpoint_condition(
1927+ fn impl_edit_breakpoint(
1928 cx: &mut compositor::Context,
1928 cx: &mut compositor::Context,
1929− args: &[&str],
1929+ condition: Option<String>,
1930− _event: PromptEvent,
1930+ log_message: Option<String>,
1931− ) -> anyhow::Result<()> {
1931+ ) {
1932 use helix_lsp::block_on;
1932 use helix_lsp::block_on;
1934− let condition = args.join(" ");
1935− let condition = if condition.is_empty() {
1941 let (view, doc) = current!(cx.editor);
1934 let (view, doc) = current!(cx.editor);
1942 let text = doc.text().slice(..);
1935 let text = doc.text().slice(..);
1943 let pos = doc.selection(view.id).primary().cursor(text);
1936 let pos = doc.selection(view.id).primary().cursor(text);
1945 let breakpoint = helix_dap::SourceBreakpoint {
1937 let breakpoint = helix_dap::SourceBreakpoint {
1946 line: text.char_to_line(pos) + 1, // convert from 0-indexing to 1-indexing (TODO: could set debugger to 0-indexing on init)
1938 line: text.char_to_line(pos) + 1, // convert from 0-indexing to 1-indexing (TODO: could set debugger to 0-indexing on init)
1947 condition,
1939 condition,
1948 ..Default::default()
1941 ..Default::default()
1951 let path = match doc.path() {
1943 let path = match doc.path() {
1952 Some(path) => path.to_path_buf(),
1944 Some(path) => path.to_path_buf(),
1953 None => {
1945 None => {
1954 cx.editor
1946 cx.editor
1955 .set_error("Can't edit breakpoint: document has no path".to_string());
1947 .set_error("Can't edit breakpoint: document has no path".to_string());
1956− return Ok(());
1948+ return;
1960− // TODO: need to map breakpoints over edits and update them?
1961− // we shouldn't really allow editing while debug is running though
1963 if let Some(debugger) = &mut cx.editor.debugger {
1951 if let Some(debugger) = &mut cx.editor.debugger {
1964 let breakpoints = debugger.breakpoints.entry(path.clone()).or_default();
1952 let breakpoints = debugger.breakpoints.entry(path.clone()).or_default();
1965 if let Some(pos) = breakpoints.iter().position(|b| b.line == breakpoint.line) {
1953 if let Some(pos) = breakpoints.iter().position(|b| b.line == breakpoint.line) {
@@ -1972,6 +1960,37 @@ mod cmd {
1972 let _ = block_on(request).unwrap();
1960 let _ = block_on(request).unwrap();
1965+ fn debug_breakpoint_condition(
1966+ cx: &mut compositor::Context,
1968+ _event: PromptEvent,
1969+ ) -> anyhow::Result<()> {
1970+ let condition = args.join(" ");
1971+ let condition = if condition.is_empty() {
1977+ impl_edit_breakpoint(cx, condition, None);
1981+ fn debug_set_logpoint(
1982+ cx: &mut compositor::Context,
1984+ _event: PromptEvent,
1985+ ) -> anyhow::Result<()> {
1986+ let log_message = args.join(" ");
1987+ let log_message = if log_message.is_empty() {
1993+ impl_edit_breakpoint(cx, None, log_message);
@@ -2227,6 +2246,13 @@ mod cmd {
2227 doc: "Set current breakpoint condition.",
2246 doc: "Set current breakpoint condition.",
2228 fun: debug_breakpoint_condition,
2247 fun: debug_breakpoint_condition,
2229 completer: None,
2248 completer: None,
2251+ name: "debug-set-logpoint",
2253+ doc: "Make current breakpoint a log point.",
2254+ fun: debug_set_logpoint,