Implement basic support for VS Code debug configurations (#29160)

- [x] Basic implementation
- [x] Match common VSC debug extension names to Zed debug adapters
- [ ] ~~`preLaunchTask` support~~ descoped for this PR

Release Notes:

- N/A
This commit is contained in:
Cole Miller 2025-04-22 10:24:09 -04:00 committed by GitHub
parent 36d02de784
commit 207fb04969
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 269 additions and 46 deletions

View file

@ -7,7 +7,8 @@ use gpui::{App, AsyncApp, BorrowAppContext, Context, Entity, EventEmitter, Task}
use lsp::LanguageServerName;
use paths::{
EDITORCONFIG_NAME, local_debug_file_relative_path, local_settings_file_relative_path,
local_tasks_file_relative_path, local_vscode_tasks_file_relative_path,
local_tasks_file_relative_path, local_vscode_launch_file_relative_path,
local_vscode_tasks_file_relative_path,
};
use rpc::{
AnyProtoClient, TypedEnvelope,
@ -24,7 +25,7 @@ use std::{
sync::Arc,
time::Duration,
};
use task::{TaskTemplates, VsCodeTaskFile};
use task::{DebugTaskFile, TaskTemplates, VsCodeDebugTaskFile, VsCodeTaskFile};
use util::{ResultExt, serde::default_true};
use worktree::{PathChange, UpdatedEntriesSet, Worktree, WorktreeId};
@ -573,6 +574,18 @@ impl SettingsObserver {
.unwrap(),
);
(settings_dir, LocalSettingsKind::Tasks(TaskKind::Debug))
} else if path.ends_with(local_vscode_launch_file_relative_path()) {
let settings_dir = Arc::<Path>::from(
path.ancestors()
.nth(
local_vscode_tasks_file_relative_path()
.components()
.count()
.saturating_sub(1),
)
.unwrap(),
);
(settings_dir, LocalSettingsKind::Tasks(TaskKind::Debug))
} else if path.ends_with(EDITORCONFIG_NAME) {
let Some(settings_dir) = path.parent().map(Arc::from) else {
continue;
@ -618,6 +631,23 @@ impl SettingsObserver {
"serializing Zed tasks into JSON, file {abs_path:?}"
)
})
} else if abs_path.ends_with(local_vscode_launch_file_relative_path()) {
let vscode_tasks =
parse_json_with_comments::<VsCodeDebugTaskFile>(&content)
.with_context(|| {
format!("parsing VSCode debug tasks, file {abs_path:?}")
})?;
let zed_tasks = DebugTaskFile::try_from(vscode_tasks)
.with_context(|| {
format!(
"converting VSCode debug tasks into Zed ones, file {abs_path:?}"
)
})?;
serde_json::to_string(&zed_tasks).with_context(|| {
format!(
"serializing Zed tasks into JSON, file {abs_path:?}"
)
})
} else {
Ok(content)
}