@@ -1924,6 +1924,57 @@ mod cmd {
1927+ fn debug_breakpoint_condition(
1928+ cx: &mut compositor::Context,
1930+ _event: PromptEvent,
1931+ ) -> anyhow::Result<()> {
1932+ use helix_lsp::block_on;
1934+ let condition = args.join(" ");
1935+ let condition = if condition.len() > 0 {
1941+ let (view, doc) = current!(cx.editor);
1942+ let text = doc.text().slice(..);
1943+ let pos = doc.selection(view.id).primary().cursor(text);
1945+ 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)
1948+ ..Default::default()
1951+ let path = match doc.path() {
1952+ Some(path) => path.to_path_buf(),
1955+ .set_error("Can't edit breakpoint: document has no path".to_string());
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 {
1964+ let breakpoints = debugger.breakpoints.entry(path.clone()).or_default();
1965+ if let Some(pos) = breakpoints.iter().position(|b| b.line == breakpoint.line) {
1966+ breakpoints.remove(pos);
1967+ breakpoints.push(breakpoint);
1969+ let breakpoints = breakpoints.clone();
1971+ let request = debugger.set_breakpoints(path, breakpoints);
1972+ let _ = block_on(request).unwrap();
1927 pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
1978 pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
1928 TypableCommand {
1979 TypableCommand {
1929 name: "quit",
1980 name: "quit",
@@ -2169,6 +2220,13 @@ mod cmd {
2169 doc: "Evaluate expression in current debug context.",
2220 doc: "Evaluate expression in current debug context.",
2170 fun: debug_eval,
2221 fun: debug_eval,
2171 completer: None,
2222 completer: None,
2225+ name: "debug-breakpoint-condition",
2227+ doc: "Set current breakpoint condition.",
2228+ fun: debug_breakpoint_condition,