Skip to content

The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.

1.1 KB
Raw Blame
/**
 * Settings › Debugger › Breakpoints › "Allow placing breakpoints in any file":
 * when off, new line breakpoints go only into files of languages that have a
 * debug adapter (`languages/*.toml` `[debugger]`).
 */
import { classFileBreakpointReason } from "@/platform/classFiles";
import { commands, isTauri } from "@/platform/ipc";
import { workflowSettings } from "@/platform/workflowSettings";

let debuggable: Set<string> | null = null;
let loading = false;

function load() {
  if (debuggable || loading || !isTauri()) return;
  loading = true;
  commands
    .languages()
    .then((langs) => {
      debuggable = new Set(langs.filter((l) => l.debuggable).map((l) => l.id));
    })
    .catch(() => undefined)
    .finally(() => (loading = false));
}

/** Whether a new breakpoint may be placed in a file of `language`. */
export function canPlaceBreakpoint(language: string, path = ""): boolean {
  if (classFileBreakpointReason(path)) return false;
  if (workflowSettings().debugger.breakpointsAnyFile) return true;
  load();
  // Until the language list is known, don't block anything.
  return !debuggable || debuggable.has(language);
}