Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions src/odin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,11 @@ impl zed::Extension for OdinExtension {
resolved_label: String,
debug_adapter_name: String,
) -> Option<DebugScenario> {
// Only handle Odin run tasks
if build_task.command != "odin" || build_task.args.is_empty() || build_task.args[0] != "run"
{
let is_run = build_task.command == "odin" && build_task.args.first() == Some(&"run".into());
let is_test =
build_task.command == "odin" && build_task.args.first() == Some(&"test".into());

if !is_run && !is_test {
return None;
}

Expand All @@ -449,9 +451,17 @@ impl zed::Extension for OdinExtension {
build_args.push("-debug".into());
}

if is_test {
build_args.push("-build-mode:test".into())
}

// Create the build task template
let build_template = BuildTaskTemplate {
label: "odin debug build".into(),
label: if is_test {
"odin debug test".into()
} else {
"odin debug build".into()
},
command: build_task.command.clone(),
args: build_args,
env: build_task.env.clone(),
Expand All @@ -461,13 +471,20 @@ impl zed::Extension for OdinExtension {
// Config is Null - the actual launch config comes from run_dap_locator
let config = serde_json::to_string(&serde_json::Value::Null).ok()?;

// Remove 'run: ' from the task label, since 'debug: ' will be prepended by default
let label = resolved_label
.clone()
// Remove the prefix from the task label, since 'debug: ' will be prepended by default if no prefix is provided
let base_label = resolved_label
.strip_prefix("run: ")
.or_else(|| resolved_label.strip_prefix("test: "))
.unwrap_or(&resolved_label)
.to_string();

// Add a special prefix to clarify debugging tests
let label = if is_test {
format!("debug test: {}", base_label)
} else {
base_label
};
Copy link
Collaborator

@rxptr rxptr Jan 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this is redundant; in the debug modal, every task is a debug task. But specifically it makes the run button in the gutter look awkward:

Image

Copy link
Contributor Author

@NANDquark NANDquark Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good point, thanks for noticing that. I didn't realize the same task would show up in the gutter as well.

By just reverting these few changes I think it looks pretty good leaving that "test: " prefix on it.

image image


Some(DebugScenario {
adapter: debug_adapter_name,
label,
Expand All @@ -487,12 +504,12 @@ impl zed::Extension for OdinExtension {
_locator_name: String,
build_task: TaskTemplate,
) -> Result<DebugRequest, String> {
// Only handle Odin build tasks
// Only handle Odin build and test tasks
if build_task.command != "odin"
|| build_task.args.is_empty()
|| build_task.args[0] != "build"
|| !(build_task.args[0] == "build" || build_task.args[0] == "test")
{
return Err("Not an Odin build task".to_string());
return Err("Not an Odin build or test task".to_string());
}

// Extract the binary name from the -out: flag
Expand Down