дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-23 10:00:48 +02:00
Порівняти коміти
1
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
9b59961127 |
No files matched your search
@@ -80,7 +80,6 @@ Shared agent skills live in `.agents/skills/` (`.claude/skills/` links to them):
|
||||
this worktree's running MCP bridges and actual ports.
|
||||
- `pnpm build` — typecheck + bundle frontend.
|
||||
- `pnpm dogfood:build` / `pnpm dogfood:install` (or `mise run dogfood:build` / `mise run dogfood:install`) — build and locally install the grey-icon dogfood desktop app sharing release settings and data.
|
||||
- `pnpm dogfood:remote <remote_name> [--restart | --no-restart] [--clean]` (or `mise run dogfood:remote <remote_name>`) — sync backend sources to a host from **Tools › SSH Configurations**, build `openidea-server`, and stage it for Remote Development.
|
||||
- `cargo nextest run --workspace` (or `cargo test`), `cargo clippy --workspace --all-targets -- -D warnings`, `cargo fmt --all`.
|
||||
- `cargo test -p ide-host --test language_smoke -- --ignored --exact <language>` — code intelligence
|
||||
on `fixtures/` with that language's real server installed (CI: `Language smoke`, pinned versions).
|
||||
|
||||
Створено
@@ -4846,7 +4846,6 @@ dependencies = [
|
||||
name = "ide-sdk"
|
||||
version = "0.1.50"
|
||||
dependencies = [
|
||||
"dirs 6.0.0",
|
||||
"dunce",
|
||||
"flate2",
|
||||
"ide-core",
|
||||
|
||||
@@ -63,9 +63,6 @@ pub type NewTaskApprovalsHook = Arc<dyn Fn() -> ide_core::settings::NewTaskAppro
|
||||
/// attached projects the user trusts.
|
||||
pub type WorkspaceRootsHook = Arc<dyn Fn() -> Vec<PathBuf> + Send + Sync>;
|
||||
|
||||
/// Returns the project's git executable (`None`: the default), which the tasks' git runs.
|
||||
pub type GitExecutableHook = Arc<dyn Fn() -> Option<PathBuf> + Send + Sync>;
|
||||
|
||||
/// Entry changes are batched for this long before they are sent.
|
||||
const FLUSH_DELAY: Duration = Duration::from_millis(40);
|
||||
/// Updates that arrive this late after `session/load` returns are still replayed history.
|
||||
@@ -188,7 +185,6 @@ struct Shared {
|
||||
security: RwLock<Option<SecurityHook>>,
|
||||
new_task_approvals: RwLock<Option<NewTaskApprovalsHook>>,
|
||||
workspace_roots: RwLock<Option<WorkspaceRootsHook>>,
|
||||
git_executable: RwLock<Option<GitExecutableHook>>,
|
||||
known: Arc<Mutex<HashMap<String, Known>>>,
|
||||
providers: RwLock<Vec<provider::ProviderSpec>>,
|
||||
/// Last probe of each provider.
|
||||
@@ -603,7 +599,6 @@ impl AgentManager {
|
||||
security: RwLock::new(None),
|
||||
new_task_approvals: RwLock::new(None),
|
||||
workspace_roots: RwLock::new(None),
|
||||
git_executable: RwLock::new(None),
|
||||
known,
|
||||
providers,
|
||||
probes: Mutex::new(HashMap::new()),
|
||||
@@ -676,11 +671,6 @@ impl AgentManager {
|
||||
*self.shared.workspace_roots.write() = Some(hook);
|
||||
}
|
||||
|
||||
/// Sets the callback that reads the project's git executable.
|
||||
pub fn set_git_executable_hook(&self, hook: GitExecutableHook) {
|
||||
*self.shared.git_executable.write() = Some(hook);
|
||||
}
|
||||
|
||||
/// The agents (custom ones re-read), whether each is installed, and what they offered last time.
|
||||
pub fn providers(&self) -> Vec<AgentProvider> {
|
||||
let specs = provider::load(self.shared.paths.custom_agents_dir.as_deref(), self.shared.env_secrets());
|
||||
@@ -993,15 +983,14 @@ impl AgentManager {
|
||||
}
|
||||
let dir = self.shared.paths.worktrees_dir.clone();
|
||||
let (t, b) = (title.clone(), req.base.clone());
|
||||
let c = vcs(&self.shared, move || worktree::create(&root, &dir, &t, b.as_deref())).await?;
|
||||
let c = blocking(move || worktree::create(&root, &dir, &t, b.as_deref())).await?;
|
||||
(c.path, Some(c.branch), Some(c.base), Some(c.base_commit), BTreeMap::new())
|
||||
}
|
||||
Isolation::Local => {
|
||||
let r = root.clone();
|
||||
let (head, before) = vcs(&self.shared, move || {
|
||||
Ok((worktree::head_of(&r).ok(), worktree::snapshot(&r).unwrap_or_default()))
|
||||
})
|
||||
.await?;
|
||||
let (head, before) =
|
||||
blocking(move || Ok((worktree::head_of(&r).ok(), worktree::snapshot(&r).unwrap_or_default())))
|
||||
.await?;
|
||||
let (base, commit) = head.unzip();
|
||||
(root, None, base, commit, before)
|
||||
}
|
||||
@@ -1035,7 +1024,7 @@ impl AgentManager {
|
||||
} else {
|
||||
let name = format!("{id}.before");
|
||||
let (dir, at, files) = (self.shared.paths.store_dir.join(&name), cwd.clone(), before.clone());
|
||||
match vcs(&self.shared, move || worktree::save_before(&at, &files, &dir)).await {
|
||||
match blocking(move || worktree::save_before(&at, &files, &dir)).await {
|
||||
Ok(saved) => saved.then_some(name),
|
||||
Err(e) => {
|
||||
tracing::warn!("saving the changed files of agent task {id}: {e}");
|
||||
@@ -1837,7 +1826,7 @@ impl AgentManager {
|
||||
let _ = tokio::time::timeout(EXIT_WAIT, peer.exited()).await;
|
||||
}
|
||||
let worktrees = self.shared.paths.worktrees_dir.clone();
|
||||
vcs(&self.shared, move || worktree::remove(&root, &worktrees, &cwd)).await?;
|
||||
blocking(move || worktree::remove(&root, &worktrees, &cwd)).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -1847,7 +1836,7 @@ impl AgentManager {
|
||||
let task = self.task(id)?;
|
||||
let at = task.base();
|
||||
let (before, touched) = task.attribution();
|
||||
vcs(&self.shared, move || Ok(worktree::made_by_task(at.changes(&before)?, touched.as_deref()))).await
|
||||
blocking(move || Ok(worktree::made_by_task(at.changes(&before)?, touched.as_deref()))).await
|
||||
}
|
||||
|
||||
/// The task's uncommitted changes and, for a worktree task, the commits made since it
|
||||
@@ -1856,7 +1845,7 @@ impl AgentManager {
|
||||
let task = self.task(id)?;
|
||||
let at = task.base();
|
||||
let (before, touched) = task.attribution();
|
||||
vcs(&self.shared, move || {
|
||||
blocking(move || {
|
||||
let mut grouped = at.grouped_changes(&before)?;
|
||||
grouped.uncommitted = worktree::made_by_task(grouped.uncommitted, touched.as_deref());
|
||||
Ok(grouped)
|
||||
@@ -1869,7 +1858,7 @@ impl AgentManager {
|
||||
pub async fn turn_changes(&self, id: &str) -> IdeResult<Vec<AgentChange>> {
|
||||
let (cwd, turn, dir) = self.task(id)?.last_turn();
|
||||
let Some(turn) = turn else { return Ok(Vec::new()) };
|
||||
vcs(&self.shared, move || {
|
||||
blocking(move || {
|
||||
let changed = match &turn.changed {
|
||||
Some(changed) => changed.clone(),
|
||||
None => worktree::changed_in_turn(&cwd, &turn)?.1,
|
||||
@@ -1886,10 +1875,10 @@ impl AgentManager {
|
||||
if view == AgentChangesView::LastTurn {
|
||||
let (cwd, turn, dir) = task.last_turn();
|
||||
let Some(turn) = turn else { return Ok(None) };
|
||||
return vcs(&self.shared, move || worktree::turn_text(&cwd, &path, &turn, &dir)).await;
|
||||
return blocking(move || worktree::turn_text(&cwd, &path, &turn, &dir)).await;
|
||||
}
|
||||
let at = task.base();
|
||||
vcs(&self.shared, move || {
|
||||
blocking(move || {
|
||||
let rev = match view {
|
||||
AgentChangesView::Group => worktree::head_commit(at.cwd())?,
|
||||
_ => at.rev()?,
|
||||
@@ -1923,7 +1912,7 @@ impl AgentManager {
|
||||
let s = task.state.lock();
|
||||
(s.before.clone(), s.saved.as_ref().map(|name| self.shared.paths.store_dir.join(name)), s.touched.clone())
|
||||
};
|
||||
let (restamped, restored) = vcs(&self.shared, move || {
|
||||
let (restamped, restored) = blocking(move || {
|
||||
let (changes, rev) = match view {
|
||||
AgentChangesView::Group => (at.grouped_changes(&before)?.uncommitted, worktree::head_commit(at.cwd())?),
|
||||
AgentChangesView::SinceStart | AgentChangesView::LastTurn => (at.changes(&before)?, at.rev()?),
|
||||
@@ -1979,7 +1968,7 @@ impl AgentManager {
|
||||
let s = task.state.lock();
|
||||
(s.before.clone(), s.saved.as_ref().map(|name| self.shared.paths.store_dir.join(name)))
|
||||
};
|
||||
let restamped = vcs(&self.shared, move || {
|
||||
let restamped = blocking(move || {
|
||||
let changed = match &turn.changed {
|
||||
Some(changed) => changed.clone(),
|
||||
None => worktree::changed_in_turn(&cwd, &turn)?.1,
|
||||
@@ -2036,7 +2025,7 @@ impl AgentManager {
|
||||
let Some(base) = base else {
|
||||
return Err(IdeError::invalid("the task has no base revision to accept from"));
|
||||
};
|
||||
vcs(&self.shared, move || {
|
||||
blocking(move || {
|
||||
let wanted: Vec<AgentChange> = worktree::without_untouched(worktree::changes(&cwd, &base)?, &before)
|
||||
.into_iter()
|
||||
.filter(|c| rel_paths.as_ref().is_none_or(|p| p.contains(&c.rel_path)))
|
||||
@@ -2291,7 +2280,7 @@ impl Task {
|
||||
/// Records the checkout as a turn starts: what the turn's changes are compared with.
|
||||
async fn checkout_before_turn(&self) {
|
||||
let (cwd, previous, dir) = self.last_turn();
|
||||
let turn = match vcs(&self.shared, move || worktree::start_turn(&cwd, &dir, previous.as_deref())).await {
|
||||
let turn = match blocking(move || worktree::start_turn(&cwd, &dir, previous.as_deref())).await {
|
||||
Ok(turn) => Some(Arc::new(turn)),
|
||||
Err(e) => {
|
||||
tracing::warn!("recording the checkout as a turn of agent task {} starts: {e}", self.id);
|
||||
@@ -2308,9 +2297,7 @@ impl Task {
|
||||
let (cwd, turn, _) = self.last_turn();
|
||||
let Some(turn) = turn else { return };
|
||||
let start = turn.clone();
|
||||
let Ok((in_worktree, all)) = vcs(&self.shared, move || worktree::changed_in_turn(&cwd, &start)).await else {
|
||||
return;
|
||||
};
|
||||
let Ok((in_worktree, all)) = blocking(move || worktree::changed_in_turn(&cwd, &start)).await else { return };
|
||||
{
|
||||
let mut s = self.state.lock();
|
||||
if !in_worktree.is_empty()
|
||||
@@ -4264,12 +4251,6 @@ async fn blocking<T: Send + 'static>(f: impl FnOnce() -> IdeResult<T> + Send + '
|
||||
tokio::task::spawn_blocking(f).await.map_err(|e| IdeError::internal(e.to_string()))?
|
||||
}
|
||||
|
||||
/// [`blocking`] for work that runs git: the repositories it opens run the project's git.
|
||||
async fn vcs<T: Send + 'static>(shared: &Shared, f: impl FnOnce() -> IdeResult<T> + Send + 'static) -> IdeResult<T> {
|
||||
let git = shared.git_executable.read().as_ref().and_then(|hook| hook());
|
||||
blocking(move || ide_vcs::with_git_executable(git.as_deref(), f)).await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod replay;
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -948,12 +948,6 @@ pub struct AgentSkill {
|
||||
/// True when frontmatter sets `disable-model-invocation: true` (defaults to `slashOnly`).
|
||||
#[serde(default)]
|
||||
pub disable_model_invocation: bool,
|
||||
/// True when frontmatter sets `context: fork` (passed through natively to supporting CLIs).
|
||||
#[serde(default)]
|
||||
pub context_fork: bool,
|
||||
/// Optional `paths` / `globs` patterns from frontmatter (passed through natively to supporting CLIs).
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub paths: Vec<String>,
|
||||
/// The `SKILL.md` passes validation (`name` matches its folder, `description` present).
|
||||
pub valid: bool,
|
||||
/// What validation found (`name` mismatch, missing or over-long description…).
|
||||
|
||||
@@ -125,9 +125,10 @@ fn file_name(path: &Path) -> Option<String> {
|
||||
path.file_name()?.to_str().map(str::to_owned)
|
||||
}
|
||||
|
||||
/// The `key: value` lines between the leading `---` fences (folded `>` / `|` values joined).
|
||||
struct Frontmatter {
|
||||
fields: Vec<(String, String)>,
|
||||
lists: Vec<(String, Vec<String>)>,
|
||||
/// Where the body starts.
|
||||
body: usize,
|
||||
}
|
||||
|
||||
@@ -137,42 +138,22 @@ impl Frontmatter {
|
||||
let mut lines = text.split_inclusive('\n');
|
||||
let mut offset = 0;
|
||||
let mut fields: Vec<(String, String)> = Vec::new();
|
||||
let mut lists: Vec<(String, Vec<String>)> = Vec::new();
|
||||
match lines.next() {
|
||||
Some(first) if first.trim_end() == "---" => offset += first.len(),
|
||||
_ => return Self { fields, lists, body: 0 },
|
||||
_ => return Self { fields, body: 0 },
|
||||
}
|
||||
for line in lines {
|
||||
offset += line.len();
|
||||
let line = line.trim_end();
|
||||
if line == "---" {
|
||||
return Self { fields, lists, body: offset };
|
||||
return Self { fields, body: offset };
|
||||
}
|
||||
let unindented_list_item = (line == "-" || line.starts_with("- ") || line.starts_with("-\t"))
|
||||
&& fields.last().is_some_and(|(_, v)| v.is_empty());
|
||||
if line.starts_with([' ', '\t']) || unindented_list_item {
|
||||
let trimmed = line.trim();
|
||||
if let Some(rest) = trimmed.strip_prefix('-')
|
||||
&& (rest.is_empty() || rest.starts_with([' ', '\t']))
|
||||
&& let Some((key, _)) = fields.last()
|
||||
{
|
||||
let item = unquote(rest.trim());
|
||||
if !item.is_empty() {
|
||||
if let Some((_, existing)) = lists.iter_mut().find(|(k, _)| k == key) {
|
||||
existing.push(item.to_owned());
|
||||
} else {
|
||||
lists.push((key.clone(), vec![item.to_owned()]));
|
||||
}
|
||||
}
|
||||
if unindented_list_item {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if line.starts_with([' ', '\t']) {
|
||||
if let Some((_, value)) = fields.last_mut() {
|
||||
if !value.is_empty() {
|
||||
value.push(' ');
|
||||
}
|
||||
value.push_str(trimmed);
|
||||
value.push_str(line.trim());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -183,15 +164,11 @@ impl Frontmatter {
|
||||
}
|
||||
}
|
||||
// No closing fence: not frontmatter.
|
||||
Self { fields: Vec::new(), lists: Vec::new(), body: 0 }
|
||||
Self { fields: Vec::new(), body: 0 }
|
||||
}
|
||||
|
||||
fn get(&self, key: &str) -> Option<&str> {
|
||||
self.fields.iter().find(|(k, _)| k.eq_ignore_ascii_case(key)).map(|(_, v)| v.as_str())
|
||||
}
|
||||
|
||||
fn list(&self, key: &str) -> Option<&[String]> {
|
||||
self.lists.iter().find(|(k, _)| k.eq_ignore_ascii_case(key)).map(|(_, v)| v.as_slice())
|
||||
self.fields.iter().find(|(k, _)| k == key).map(|(_, v)| v.as_str())
|
||||
}
|
||||
|
||||
/// `description`, else the body's first line.
|
||||
@@ -528,8 +505,6 @@ fn parse_skill_file(dir: &Path, folder: &str, text: &str, source: AgentSkillSour
|
||||
let hint = meta.get("argument-hint").map(|h| strip_ansi(h).trim().to_owned()).filter(|h| !h.is_empty());
|
||||
let user_invocable = !meta.get("user-invocable").is_some_and(|v| v.eq_ignore_ascii_case("false"));
|
||||
let disable_model_invocation = meta.get("disable-model-invocation").is_some_and(|v| v.eq_ignore_ascii_case("true"));
|
||||
let context_fork = meta.get("context").is_some_and(|v| strip_ansi(v).trim().eq_ignore_ascii_case("fork"));
|
||||
let paths = parse_skill_paths(&meta);
|
||||
AgentSkill {
|
||||
name,
|
||||
description: truncate(&description),
|
||||
@@ -539,35 +514,11 @@ fn parse_skill_file(dir: &Path, folder: &str, text: &str, source: AgentSkillSour
|
||||
also_in: Vec::new(),
|
||||
user_invocable,
|
||||
disable_model_invocation,
|
||||
context_fork,
|
||||
paths,
|
||||
valid: warnings.is_empty(),
|
||||
warnings,
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_skill_paths(meta: &Frontmatter) -> Vec<String> {
|
||||
for key in ["paths", "globs"] {
|
||||
if let Some(items) = meta.list(key) {
|
||||
let cleaned: Vec<String> =
|
||||
items.iter().map(|s| strip_ansi(s).trim().to_owned()).filter(|s| !s.is_empty()).collect();
|
||||
if !cleaned.is_empty() {
|
||||
return cleaned;
|
||||
}
|
||||
}
|
||||
if let Some(raw) = meta.get(key) {
|
||||
let trimmed = strip_ansi(raw);
|
||||
let inner = trimmed.trim().strip_prefix('[').and_then(|s| s.strip_suffix(']')).unwrap_or(trimmed.trim());
|
||||
let cleaned: Vec<String> =
|
||||
inner.split(',').map(|p| unquote(p.trim()).trim().to_owned()).filter(|p| !p.is_empty()).collect();
|
||||
if !cleaned.is_empty() {
|
||||
return cleaned;
|
||||
}
|
||||
}
|
||||
}
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
/// A skill's mode, as one policy layer of the settings has it.
|
||||
type Policies = BTreeMap<String, AgentSkillPolicy>;
|
||||
|
||||
@@ -1083,8 +1034,6 @@ mod tests {
|
||||
also_in: Vec::new(),
|
||||
user_invocable: true,
|
||||
disable_model_invocation: false,
|
||||
context_fork: false,
|
||||
paths: Vec::new(),
|
||||
valid: true,
|
||||
warnings: Vec::new(),
|
||||
}
|
||||
@@ -1486,40 +1435,4 @@ mod tests {
|
||||
let _ = stage(&farm, "claude", &off_states, &ws, Some(&home)).unwrap();
|
||||
assert!(!farm.join(".claude/skills/release-notes").exists());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_context_fork_and_paths_frontmatter_and_preserves_file_on_stage() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let root = dunce::canonicalize(tmp.path()).unwrap();
|
||||
let ws = root.join("ws");
|
||||
let raw_md = "---\n\
|
||||
name: verify-ux\n\
|
||||
description: Verify UX layouts in an isolated subagent\n\
|
||||
context: fork\n\
|
||||
paths:\n\
|
||||
- \"src/**/*.tsx\"\n\
|
||||
- crates/ide-agent/**/*.rs\n\
|
||||
---\n\nRun visual checks.\n";
|
||||
write(&ws.join(".openidea/skills/verify-ux/SKILL.md"), raw_md);
|
||||
write(
|
||||
&ws.join(".agents/skills/inline-globs/SKILL.md"),
|
||||
"---\nname: inline-globs\ndescription: Scoped by globs\nglobs: [\"e2e/*.spec.ts\", \"src/ui/*.tsx\"]\n---\n",
|
||||
);
|
||||
|
||||
let found = discover_skills(&ws, None);
|
||||
let verify = found.iter().find(|s| s.name == "verify-ux").unwrap();
|
||||
assert!(verify.context_fork);
|
||||
assert_eq!(verify.paths, ["src/**/*.tsx", "crates/ide-agent/**/*.rs"]);
|
||||
|
||||
let inline = found.iter().find(|s| s.name == "inline-globs").unwrap();
|
||||
assert!(!inline.context_fork);
|
||||
assert_eq!(inline.paths, ["e2e/*.spec.ts", "src/ui/*.tsx"]);
|
||||
|
||||
// Staging passes `SKILL.md` through untouched so native CLIs execute `context: fork` / `paths`.
|
||||
let states = resolve(found, None, &BTreeMap::new(), &BTreeMap::new(), true);
|
||||
let farm = farm_dir(&root.join("store"), "fork-passthrough");
|
||||
let _ = stage(&farm, "copilot", &states, &ws, None).unwrap();
|
||||
let staged_md = std::fs::read_to_string(farm.join("copilot/verify-ux/SKILL.md")).unwrap();
|
||||
assert_eq!(staged_md, raw_md);
|
||||
}
|
||||
}
|
||||
@@ -1206,7 +1206,6 @@ pub struct LanguagesSettings {
|
||||
pub typescript: TypeScriptSettings,
|
||||
pub prettier: ExternalFormatterSettings,
|
||||
pub oxfmt: ExternalFormatterSettings,
|
||||
pub biome: ExternalFormatterSettings,
|
||||
pub ruff: ExternalFormatterSettings,
|
||||
pub java: JavaSettings,
|
||||
pub ruby: RubySettings,
|
||||
@@ -1227,10 +1226,6 @@ impl Default for LanguagesSettings {
|
||||
typescript: TypeScriptSettings::default(),
|
||||
prettier: ExternalFormatterSettings::default(),
|
||||
oxfmt: ExternalFormatterSettings::default(),
|
||||
biome: ExternalFormatterSettings {
|
||||
languages: BIOME_LANGUAGES.iter().map(|&l| l.into()).collect(),
|
||||
..ExternalFormatterSettings::default()
|
||||
},
|
||||
ruff: ExternalFormatterSettings {
|
||||
languages: vec!["python".into()],
|
||||
..ExternalFormatterSettings::default()
|
||||
@@ -1302,7 +1297,6 @@ impl LanguagesSettings {
|
||||
match tool {
|
||||
ExternalFormatter::Prettier => &self.prettier,
|
||||
ExternalFormatter::Oxfmt => &self.oxfmt,
|
||||
ExternalFormatter::Biome => &self.biome,
|
||||
ExternalFormatter::Ruff => &self.ruff,
|
||||
}
|
||||
}
|
||||
@@ -1314,7 +1308,6 @@ impl LanguagesSettings {
|
||||
pub enum ExternalFormatter {
|
||||
Prettier,
|
||||
Oxfmt,
|
||||
Biome,
|
||||
Ruff,
|
||||
}
|
||||
|
||||
@@ -1324,21 +1317,16 @@ impl ExternalFormatter {
|
||||
match self {
|
||||
Self::Prettier => "prettier",
|
||||
Self::Oxfmt => "oxfmt",
|
||||
Self::Biome => "biome",
|
||||
Self::Ruff => "ruff",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The languages Biome formats (of those Prettier formats).
|
||||
pub const BIOME_LANGUAGES: [&str; 8] =
|
||||
["css", "graphql", "javascript", "javascriptreact", "typescript", "typescriptreact", "json", "jsonc"];
|
||||
|
||||
/// An external formatter (Prettier, oxfmt, Biome, Ruff) and the languages it formats.
|
||||
/// An external formatter (Prettier, oxfmt, Ruff) and the languages it formats.
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Type)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
pub struct ExternalFormatterSettings {
|
||||
/// Empty path: project node_modules (Prettier/oxfmt/Biome), managed installation, then PATH.
|
||||
/// Empty path: project node_modules (Prettier/oxfmt), managed installation, then PATH.
|
||||
pub path: String,
|
||||
/// Ruff only: directory containing its configuration, or a configuration file.
|
||||
pub configuration_directory: String,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use crate::Host;
|
||||
use ide_core::event::NotifyLevel;
|
||||
use ide_core::settings::{BIOME_LANGUAGES, ExternalFormatter, LanguagesSettings, Settings};
|
||||
use ide_core::settings::{ExternalFormatter, LanguagesSettings, Settings};
|
||||
use ide_core::{ChangeSet, DocId, IdeError, IdeEvent, IdeResult, LanguageId, Pos, Range, TextEdit};
|
||||
use ide_language::{LanguageConfig, PhpAlignment, Syntax};
|
||||
use ide_lsp::types::FormatOptions;
|
||||
@@ -10,28 +10,9 @@ use ide_tools::{Tools, formatter};
|
||||
use std::path::Path;
|
||||
|
||||
const OXFMT_CONFIGS: [&str; 4] = [".oxfmtrc.json", ".oxfmtrc.jsonc", "oxfmt.config.ts", "oxfmt.config.mts"];
|
||||
/// A Biome configuration, or Biome installed as a project dependency (it then uses its defaults).
|
||||
const BIOME_MARKERS: [&str; 3] = ["biome.json", "biome.jsonc", "node_modules/@biomejs/biome/package.json"];
|
||||
|
||||
/// Reformat Code uses Biome below a Biome configuration or installation, unless the nearest
|
||||
/// configuration turns its formatter off (Biome lints, another tool formats).
|
||||
fn biome_formats(file: &Path) -> bool {
|
||||
let config = ["biome.json", "biome.jsonc"]
|
||||
.iter()
|
||||
.filter_map(|name| formatter::find_up(file, Path::new(name)))
|
||||
.max_by_key(|path| path.components().count());
|
||||
match config {
|
||||
Some(config) => !std::fs::read_to_string(&config)
|
||||
.ok()
|
||||
.and_then(|text| serde_json::from_str::<serde_json::Value>(&ide_core::jsonc::strip(&text)).ok())
|
||||
.is_some_and(|v| v.pointer("/formatter/enabled") == Some(&serde_json::Value::Bool(false))),
|
||||
None => BIOME_MARKERS.iter().any(|name| formatter::find_up(file, Path::new(name)).is_some()),
|
||||
}
|
||||
}
|
||||
|
||||
fn supports_external_format(language: &LanguageConfig, tool: ExternalFormatter) -> bool {
|
||||
match language.formatter.as_ref().map(|f| f.tool.as_str()) {
|
||||
Some("prettier") if tool == ExternalFormatter::Biome => BIOME_LANGUAGES.contains(&language.id.as_str()),
|
||||
Some("prettier") => matches!(tool, ExternalFormatter::Prettier | ExternalFormatter::Oxfmt),
|
||||
Some("ruff") => tool == ExternalFormatter::Ruff,
|
||||
_ => false,
|
||||
@@ -39,9 +20,9 @@ fn supports_external_format(language: &LanguageConfig, tool: ExternalFormatter)
|
||||
}
|
||||
|
||||
/// The external formatter of a file, for a language with an external formatter.
|
||||
/// `forced` names the tool (Reformat with Prettier, oxfmt, Biome, or Ruff). Ruff is
|
||||
/// the base formatter for Python; Biome, then oxfmt, can replace Prettier for their
|
||||
/// languages when configured or selected. A tool that cannot format the language is
|
||||
/// `forced` names the tool (Reformat with Prettier, oxfmt, or Ruff). Ruff is
|
||||
/// the base formatter for Python; oxfmt can replace Prettier for its languages
|
||||
/// when configured or selected. A tool that cannot format the language is
|
||||
/// rejected even when explicitly requested.
|
||||
fn external_tool(
|
||||
forced: Option<ExternalFormatter>,
|
||||
@@ -49,7 +30,7 @@ fn external_tool(
|
||||
file: &Path,
|
||||
settings: &LanguagesSettings,
|
||||
) -> IdeResult<Option<ExternalFormatter>> {
|
||||
use ExternalFormatter::{Biome, Oxfmt, Prettier, Ruff};
|
||||
use ExternalFormatter::{Oxfmt, Prettier, Ruff};
|
||||
let Some(language) = language.filter(|l| l.formatter.is_some()) else {
|
||||
return match forced {
|
||||
Some(tool) => Err(IdeError::invalid(format!(
|
||||
@@ -75,11 +56,8 @@ fn external_tool(
|
||||
if language.formatter.as_ref().is_some_and(|f| f.tool == "ruff") {
|
||||
return Ok(enabled(Ruff).then_some(Ruff));
|
||||
}
|
||||
let found = |names: &[&str]| names.iter().any(|name| formatter::find_up(file, Path::new(name)).is_some());
|
||||
let biome = enabled(Biome) && supports_external_format(language, Biome);
|
||||
Ok(if biome && (settings.biome.prefer || biome_formats(file)) {
|
||||
Some(Biome)
|
||||
} else if enabled(Oxfmt) && (settings.oxfmt.prefer || found(&OXFMT_CONFIGS)) {
|
||||
let oxfmt_config = || OXFMT_CONFIGS.iter().any(|name| formatter::find_up(file, Path::new(name)).is_some());
|
||||
Ok(if enabled(Oxfmt) && (settings.oxfmt.prefer || oxfmt_config()) {
|
||||
Some(Oxfmt)
|
||||
} else {
|
||||
enabled(Prettier).then_some(Prettier)
|
||||
@@ -407,7 +385,7 @@ async fn provider_edits(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use ExternalFormatter::{Biome, Oxfmt, Prettier, Ruff};
|
||||
use ExternalFormatter::{Oxfmt, Prettier, Ruff};
|
||||
use ide_core::LanguageId;
|
||||
use ide_language::LanguageRegistry;
|
||||
|
||||
@@ -450,40 +428,6 @@ mod tests {
|
||||
assert_eq!(prettier.message, "Prettier cannot format Python files");
|
||||
let oxfmt = tool(Some(Oxfmt), "python", file, &settings).unwrap_err();
|
||||
assert_eq!(oxfmt.message, "oxfmt cannot format Python files");
|
||||
let biome = tool(Some(Biome), "python", file, &settings).unwrap_err();
|
||||
assert_eq!(biome.message, "Biome cannot format Python files");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn biome_config_or_dependency_selects_biome_for_its_languages() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
std::fs::create_dir_all(root.join("web/src")).unwrap();
|
||||
let (web, api, readme) = (root.join("web/src/app.ts"), root.join("api/main.ts"), root.join("web/README.md"));
|
||||
let mut settings = LanguagesSettings::default();
|
||||
for marker in BIOME_MARKERS {
|
||||
let path = root.join("web").join(marker);
|
||||
std::fs::create_dir_all(path.parent().unwrap()).unwrap();
|
||||
std::fs::write(&path, "{}").unwrap();
|
||||
assert_eq!(tool(None, "typescript", &web, &settings).unwrap(), Some(Biome), "{marker}");
|
||||
assert_eq!(tool(None, "typescript", &api, &settings).unwrap(), Some(Prettier), "{marker}");
|
||||
// Biome doesn't format Markdown: Prettier keeps it.
|
||||
assert_eq!(tool(None, "markdown", &readme, &settings).unwrap(), Some(Prettier), "{marker}");
|
||||
std::fs::remove_file(&path).unwrap();
|
||||
}
|
||||
std::fs::write(root.join("web/biome.json"), "{}").unwrap();
|
||||
std::fs::write(root.join("web/.oxfmtrc.json"), "{}").unwrap();
|
||||
assert_eq!(tool(None, "css", &web, &settings).unwrap(), Some(Biome));
|
||||
settings.biome.languages.retain(|l| l != "css");
|
||||
assert_eq!(tool(None, "css", &web, &settings).unwrap(), Some(Oxfmt));
|
||||
// Biome only lints here: Prettier keeps formatting.
|
||||
std::fs::remove_file(root.join("web/.oxfmtrc.json")).unwrap();
|
||||
std::fs::write(root.join("web/biome.json"), r#"{ "formatter": { "enabled": false } }"#).unwrap();
|
||||
assert_eq!(tool(None, "typescript", &web, &settings).unwrap(), Some(Prettier));
|
||||
settings.biome.prefer = true;
|
||||
assert_eq!(tool(None, "typescript", &api, &settings).unwrap(), Some(Biome));
|
||||
let markdown = tool(Some(Biome), "markdown", &readme, &settings).unwrap_err();
|
||||
assert_eq!(markdown.message, "Biome cannot format Markdown files");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -25,7 +25,7 @@ pub mod rpc;
|
||||
pub mod shell_env;
|
||||
pub mod trust;
|
||||
|
||||
pub use project::{Project, history_retention};
|
||||
pub use project::{Project, apply_git_executable, history_retention};
|
||||
|
||||
use ide_core::{CancellationToken, IdeError, IdeResult, RequestId, SharedSink};
|
||||
use ide_language::{LanguageRegistry, Syntax};
|
||||
@@ -34,7 +34,7 @@ use ide_terminal::TerminalManager;
|
||||
use ide_workspace::SettingsStore;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use std::collections::HashMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::path::PathBuf;
|
||||
use std::sync::{Arc, OnceLock};
|
||||
|
||||
/// Event sink for one window (by label).
|
||||
@@ -207,7 +207,6 @@ impl Host {
|
||||
};
|
||||
host.apply_proxy();
|
||||
host.apply_added_jdks();
|
||||
host.apply_git_executable();
|
||||
// Before any project starts jdtls; the deleting itself can take a while.
|
||||
let unused =
|
||||
ide_sdk::jdtls_workspaces::take_unused(&host.local_data_dir, ide_sdk::jdtls_workspaces::UNUSED_FOR);
|
||||
@@ -599,14 +598,6 @@ impl Host {
|
||||
let homes = self.global_settings.effective().languages.java.added_jdks;
|
||||
ide_sdk::java::set_added_jdks(homes.into_iter().map(PathBuf::from));
|
||||
}
|
||||
|
||||
/// Global Settings › Version Control › Git › Path to Git executable, for git started outside
|
||||
/// a project's repositories (clone, init, agents, gh, plugins). A project's own value stays
|
||||
/// with its repositories ([`Project::repos`]).
|
||||
pub fn apply_git_executable(&self) {
|
||||
let exe = self.global_settings.read_effective(|s| s.vcs.git.executable.trim().to_owned());
|
||||
ide_vcs::set_default_git_executable((!exe.is_empty()).then(|| Path::new(&exe)));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -906,7 +906,6 @@ pub async fn build_run(
|
||||
let detected = project.detected_roots.read().clone();
|
||||
let config_dir = host.config_dir.clone();
|
||||
let token = host.begin_project_request(window, request);
|
||||
let launch_project = project.clone();
|
||||
let result = tokio::task::spawn_blocking(move || {
|
||||
// Fast path (#2476): an unchanged single-project Maven build skips
|
||||
// Maven entirely. Previous diagnostics stay: nothing changed, so they
|
||||
@@ -1004,12 +1003,7 @@ pub async fn build_run(
|
||||
};
|
||||
let result = compile::run(&root, &plan, &token, &|e| {
|
||||
let _ = on_event.send(e);
|
||||
});
|
||||
if kind == BuildKind::Rebuild {
|
||||
// The clean removed outputs that earlier launch snapshots still hold.
|
||||
launch_project.java_launch_snapshots.lock().forget_reusable_snapshots();
|
||||
}
|
||||
let result = result?;
|
||||
})?;
|
||||
if result.success && single && kind == BuildKind::Build {
|
||||
let model = with_profiles(load(&root, &cache, &settings), &cache);
|
||||
compile::record_menu_build(&cache, &root, &model, file.as_deref(), &token);
|
||||
|
||||
@@ -135,16 +135,6 @@ impl Session {
|
||||
}
|
||||
}
|
||||
|
||||
/// Build › Rebuild replaced the module outputs. The recorded snapshots were copied from
|
||||
/// the outputs before the clean and may hold classes it removed (a class moved to another
|
||||
/// package leaves its old file behind when jdtls wrote it), so none of them is reused:
|
||||
/// the next launch copies the rebuilt outputs.
|
||||
pub(crate) fn forget_reusable_snapshots(&mut self) {
|
||||
if let Err(error) = forget_reusable_snapshots(&self.cache) {
|
||||
tracing::warn!(%error, "Cannot invalidate Java launch snapshots");
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn build(
|
||||
&mut self,
|
||||
root: &Path,
|
||||
@@ -351,32 +341,6 @@ impl Drop for Session {
|
||||
}
|
||||
}
|
||||
|
||||
/// Clears the fingerprint of every launch record under `cache`, so no snapshot matches the
|
||||
/// sources any more. The records stay: their modules keep delegating to Maven.
|
||||
fn forget_reusable_snapshots(cache: &Path) -> std::io::Result<()> {
|
||||
let records = cache.join("java-launch/records");
|
||||
if !records.try_exists()? {
|
||||
return Ok(());
|
||||
}
|
||||
let mut pending = vec![records];
|
||||
while let Some(dir) = pending.pop() {
|
||||
for entry in fs::read_dir(dir)? {
|
||||
let entry = entry?;
|
||||
let kind = entry.file_type()?;
|
||||
if kind.is_dir() {
|
||||
pending.push(entry.path());
|
||||
} else if kind.is_file() && entry.path().extension().is_some_and(|ext| ext == "json") {
|
||||
let outputs: Option<Outputs> = serde_json::from_slice(&fs::read(entry.path())?).unwrap_or(None);
|
||||
if let Some(mut outputs) = outputs.filter(|o| o.fingerprint.is_some()) {
|
||||
outputs.fingerprint = None;
|
||||
write_record(&entry.path(), &outputs).map_err(|e| std::io::Error::other(e.message))?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn referenced_snapshots(cache: &Path) -> std::io::Result<HashSet<PathBuf>> {
|
||||
let mut referenced = HashSet::new();
|
||||
let records = cache.join("java-launch/records");
|
||||
@@ -646,34 +610,6 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_menu_rebuild_stops_reusing_snapshots_that_hold_removed_classes() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
let model = fixture(root);
|
||||
let cancel = CancellationToken::new();
|
||||
// A class jdtls wrote for a source since moved to another package; an incremental
|
||||
// Maven build leaves it in target/classes.
|
||||
fs::create_dir_all(root.join("target/classes")).unwrap();
|
||||
fs::write(root.join("target/classes/Stale.class"), "stale").unwrap();
|
||||
let mut session = Session::new(root.join("cache"));
|
||||
let first = session.build(root, &model, root, BuildOptions::default(), None, &cancel).unwrap();
|
||||
assert!(first.snapshot.join("0/Stale.class").is_file());
|
||||
let reused = session.build(root, &model, root, BuildOptions::default(), None, &cancel).unwrap();
|
||||
assert_eq!(reused.snapshot, first.snapshot);
|
||||
|
||||
// Build › Rebuild cleans the outputs and compiles again.
|
||||
fs::remove_file(root.join("target/classes/Stale.class")).unwrap();
|
||||
session.forget_reusable_snapshots();
|
||||
assert!(has_record(root, &root.join("cache"), root));
|
||||
let next = session.build(root, &model, root, BuildOptions::default(), None, &cancel).unwrap();
|
||||
assert_ne!(next.snapshot, first.snapshot);
|
||||
assert!(!next.snapshot.join("0/Stale.class").exists());
|
||||
assert!(next.snapshot.join("0/Main.class").is_file());
|
||||
let again = session.build(root, &model, root, BuildOptions::default(), None, &cancel).unwrap();
|
||||
assert_eq!(again.snapshot, next.snapshot);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn jdt_errors_reuse_an_unchanged_snapshot_and_rebuild_only_on_a_cache_miss() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -1176,22 +1176,6 @@ pub async fn lsp_prepare_rename(host: &Host, window: &str, doc: DocId, pos: Pos)
|
||||
host.project(window)?.lsp.prepare_rename(doc, pos).await
|
||||
}
|
||||
|
||||
/// The Throwable class the caret at `pos` names, for the exception breakpoint intention.
|
||||
#[command(trust = trusted)]
|
||||
pub async fn lsp_exception_class_at(
|
||||
host: &Host,
|
||||
window: &str,
|
||||
request: RequestId,
|
||||
doc: DocId,
|
||||
pos: Pos,
|
||||
) -> IdeResult<Option<ExceptionClassRef>> {
|
||||
let project = host.project(window)?;
|
||||
let cancel = host.begin_request(request);
|
||||
let result = project.lsp.exception_class_at(doc, pos, cancel).await;
|
||||
host.end_request(request);
|
||||
result
|
||||
}
|
||||
|
||||
/// The class at `pos` and the members Pull Members Up / Push Members Down can move.
|
||||
#[command(trust = trusted)]
|
||||
pub async fn lsp_hierarchy_members(
|
||||
@@ -2802,7 +2786,6 @@ ide_command::domain!(
|
||||
lsp_completion,
|
||||
lsp_document_highlights,
|
||||
lsp_document_links,
|
||||
lsp_exception_class_at,
|
||||
lsp_execute_code_action,
|
||||
lsp_execute_command,
|
||||
lsp_extract_interface,
|
||||
|
||||
@@ -391,9 +391,6 @@ pub fn set_settings(
|
||||
if key == "languages" || key == "languages.java" || key.starts_with("languages.java.addedJdks") {
|
||||
host.apply_added_jdks();
|
||||
}
|
||||
if key == "vcs" || key == "vcs.git" || key == "vcs.git.executable" {
|
||||
host.apply_git_executable();
|
||||
}
|
||||
if is_proxy {
|
||||
host.apply_proxy();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::Host;
|
||||
use crate::{Host, apply_git_executable};
|
||||
use ide_command::command;
|
||||
use ide_core::IdeResult;
|
||||
use ide_vcs::FileStatus;
|
||||
@@ -9,6 +9,9 @@ pub async fn vcs_status(host: &Host, window: &str) -> IdeResult<Vec<FileStatus>>
|
||||
let project = host.project(window)?;
|
||||
host.blocking(move || {
|
||||
let settings = project.settings.effective();
|
||||
if project.is_trusted() {
|
||||
apply_git_executable(&settings);
|
||||
}
|
||||
let repos = project.repos();
|
||||
if repos.is_empty() {
|
||||
return Err(ide_core::IdeError::unavailable("project is not a git repository"));
|
||||
@@ -29,6 +32,9 @@ pub async fn vcs_status_paths(host: &Host, window: &str, paths: Vec<std::path::P
|
||||
let project = host.project(window)?;
|
||||
host.blocking(move || {
|
||||
let settings = project.settings.effective();
|
||||
if project.is_trusted() {
|
||||
apply_git_executable(&settings);
|
||||
}
|
||||
let repos = project.repos();
|
||||
if repos.is_empty() {
|
||||
return Err(ide_core::IdeError::unavailable("project is not a git repository"));
|
||||
|
||||
@@ -10,6 +10,8 @@ use serde::{Deserialize, Serialize};
|
||||
use specta::Type;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use crate::apply_git_executable;
|
||||
|
||||
/// Read-only repository access also works in a standalone log window.
|
||||
struct LogAccess {
|
||||
project: Option<std::sync::Arc<Project>>,
|
||||
@@ -661,6 +663,7 @@ pub async fn vcs_add_to_ignore(
|
||||
return Err(ide_core::IdeError::invalid("Ignore selection is outside the project"));
|
||||
}
|
||||
}
|
||||
apply_git_executable(&project.settings.effective());
|
||||
let result = project.with_disk_sync(|| ide_vcs::add_to_ignore(&paths, destination));
|
||||
// Exclude may live outside a worktree's watched directory. Refresh filters and UI explicitly.
|
||||
project.watcher.reload_ignore_rules();
|
||||
@@ -1053,6 +1056,7 @@ pub async fn vcs_clone(
|
||||
depth: Option<u32>,
|
||||
on_output: Channel<String>,
|
||||
) -> IdeResult<()> {
|
||||
apply_git_executable(&host.global_settings.effective());
|
||||
let cancel = host.begin_request(request);
|
||||
let result = tokio::task::spawn_blocking(move || {
|
||||
ide_vcs::clone(&url, &dest, depth, &cancel, &|line| {
|
||||
@@ -1065,12 +1069,11 @@ pub async fn vcs_clone(
|
||||
result
|
||||
}
|
||||
|
||||
/// `git init` in `dir` (VCS › Create Git Repository…): with the git of the window's project when
|
||||
/// it is trusted, the default one in a window without a project.
|
||||
/// `git init` in `dir` (File › New Project… "Create Git repository").
|
||||
#[command(trust = always)]
|
||||
pub async fn vcs_init(host: &Host, window: &str, dir: PathBuf) -> IdeResult<()> {
|
||||
let git = host.project(window).ok().and_then(|p| p.git_executable());
|
||||
blocking(move || ide_vcs::with_git_executable(git.as_deref(), || ide_vcs::init(&dir))).await
|
||||
pub async fn vcs_init(host: &Host, dir: PathBuf) -> IdeResult<()> {
|
||||
apply_git_executable(&host.global_settings.effective());
|
||||
blocking(move || ide_vcs::init(&dir)).await
|
||||
}
|
||||
|
||||
/// Settings › Git › Test: runs `git --version` on `path`, or on the auto-detected
|
||||
@@ -1346,8 +1349,14 @@ pub async fn vcs_compare_paths(
|
||||
) -> IdeResult<CompareResult> {
|
||||
let project = host.project(window)?;
|
||||
let cancel = host.begin_request(request);
|
||||
let result =
|
||||
blocking(move || project.repos().compare_paths(&paths, &revision, repositories.as_deref(), &cancel)).await;
|
||||
let result = blocking(move || {
|
||||
let settings = project.settings.effective();
|
||||
if project.is_trusted() {
|
||||
apply_git_executable(&settings);
|
||||
}
|
||||
project.repos().compare_paths(&paths, &revision, repositories.as_deref(), &cancel)
|
||||
})
|
||||
.await;
|
||||
host.end_request(request);
|
||||
result
|
||||
}
|
||||
|
||||
@@ -136,10 +136,6 @@ pub trait PluginWorkspace: Send + Sync {
|
||||
fn apply_edits(&self, path: &Path, version: u64, edits: &[TextEdit], background: bool) -> Result<u64, HostError>;
|
||||
/// Code from the project may run (git hooks and config on fetch).
|
||||
fn trusted(&self, root: &Path) -> bool;
|
||||
/// The git executable of the project at `root` (see [`crate::Project::git_executable`]).
|
||||
fn git_executable(&self, _root: &Path) -> Option<PathBuf> {
|
||||
None
|
||||
}
|
||||
/// Root of the project open in `window`.
|
||||
fn project_of(&self, window: &str) -> Option<PathBuf>;
|
||||
/// Windows showing the open project at `root`, the most recently focused first.
|
||||
@@ -1461,7 +1457,6 @@ pub(super) fn commit_draft(
|
||||
};
|
||||
// Both callers have checked that the window's project is trusted.
|
||||
r.set_execution_allowed(true);
|
||||
r.set_git_executable(workspace.git_executable(&repo.root.0).as_deref());
|
||||
let backend = &r as &dyn ide_vcs::Backend;
|
||||
let pending = backend
|
||||
.pending_changes(&repo.options, budget, &|path| Ok(workspace.vcs_encoding(path)))
|
||||
@@ -3729,10 +3724,6 @@ impl PluginWorkspace for HostWorkspace {
|
||||
HostWorkspace::project_covering(self, root).is_some_and(|p| p.is_trusted())
|
||||
}
|
||||
|
||||
fn git_executable(&self, root: &Path) -> Option<PathBuf> {
|
||||
HostWorkspace::project_covering(self, root)?.git_executable()
|
||||
}
|
||||
|
||||
fn project_of(&self, window: &str) -> Option<PathBuf> {
|
||||
self.0.upgrade()?.project(window).ok().map(|p| p.root.clone())
|
||||
}
|
||||
@@ -4737,12 +4728,8 @@ impl PluginApi {
|
||||
/// no upstream. The other reads use [`Self::read_repo`] and never execute.
|
||||
fn repo(&self, root: &Path) -> Result<Option<ide_vcs::Repo>, HostError> {
|
||||
let repo = ide_vcs::Repo::discover(root).map_err(failed)?;
|
||||
if let Some(repo) = &repo
|
||||
&& let Some(workspace) = self.shared.workspace()
|
||||
&& workspace.trusted(root)
|
||||
{
|
||||
repo.set_execution_allowed(true);
|
||||
repo.set_git_executable(workspace.git_executable(root).as_deref());
|
||||
if let Some(repo) = &repo {
|
||||
repo.set_execution_allowed(self.shared.workspace().is_some_and(|w| w.trusted(root)));
|
||||
}
|
||||
Ok(repo)
|
||||
}
|
||||
|
||||
@@ -286,10 +286,6 @@ impl Host {
|
||||
lombok.jar(),
|
||||
);
|
||||
ide_sdk::apply::configure_gradle_runtime(cfg, root, server_root, &effective);
|
||||
let gradle_dirs: Vec<_> = std::iter::once(data_dir.join("gradle"))
|
||||
.chain(dirs::cache_dir().map(|dir| dir.join("openidea").join("gradle")))
|
||||
.collect();
|
||||
ide_sdk::apply::configure_gradle_classpath(cfg, &gradle_dirs);
|
||||
ide_sdk::apply::configure_maven_sources(cfg, &effective);
|
||||
ide_sdk::jdtls::launch_directly(cfg);
|
||||
}
|
||||
@@ -696,10 +692,6 @@ impl Host {
|
||||
roots
|
||||
}));
|
||||
}
|
||||
{
|
||||
let weak = Arc::downgrade(&project);
|
||||
project.agents.set_git_executable_hook(Arc::new(move || weak.upgrade()?.git_executable()));
|
||||
}
|
||||
self.insert_project(window, project.clone());
|
||||
for (key, text, dirty) in &carried {
|
||||
let _ = project.documents.restore_untitled_buffer(key, text, *dirty);
|
||||
@@ -1077,24 +1069,11 @@ impl Project {
|
||||
);
|
||||
}
|
||||
|
||||
/// Settings › Version Control › Git › Path to Git executable, this project's value (its own
|
||||
/// layer over the global one); `None` when it is empty or the project is not trusted.
|
||||
/// Every git started for the project runs it: the project's repositories carry it, and work
|
||||
/// that opens repositories of its own (agent worktrees, gh, plugins) passes it to
|
||||
/// [`ide_vcs::with_git_executable`].
|
||||
pub fn git_executable(&self) -> Option<PathBuf> {
|
||||
let git = self.settings.read_effective(|s| s.vcs.git.executable.trim().to_owned());
|
||||
(self.is_trusted() && !git.is_empty()).then(|| PathBuf::from(git))
|
||||
}
|
||||
|
||||
/// The project's git repositories.
|
||||
pub fn repos(&self) -> Repos {
|
||||
let repos = self.repos.read().clone();
|
||||
let trusted = self.is_trusted();
|
||||
let git = self.git_executable();
|
||||
for repo in repos.all() {
|
||||
repo.set_execution_allowed(trusted);
|
||||
repo.set_git_executable(git.as_deref());
|
||||
repo.set_execution_allowed(self.is_trusted());
|
||||
}
|
||||
repos
|
||||
}
|
||||
@@ -1178,6 +1157,9 @@ impl Project {
|
||||
|
||||
fn run_in<T>(&self, repo: &Repo, f: impl FnOnce(&Repo) -> IdeResult<T>) -> IdeResult<T> {
|
||||
let settings = self.settings.effective();
|
||||
if self.is_trusted() {
|
||||
apply_git_executable(&settings);
|
||||
}
|
||||
repo.set_ignored_names(settings.ignored_names());
|
||||
repo.set_cli_status(settings.vcs.git.cli_status);
|
||||
f(repo)
|
||||
@@ -2193,6 +2175,12 @@ fn notify_transfer(sink: &SharedSink, what: &str, path: &Path, result: IdeResult
|
||||
});
|
||||
}
|
||||
|
||||
/// Settings › Version Control › Git › Path to Git executable (empty = auto-detect).
|
||||
pub fn apply_git_executable(settings: &ide_core::settings::Settings) {
|
||||
let exe = settings.vcs.git.executable.trim();
|
||||
ide_vcs::set_git_executable((!exe.is_empty()).then(|| Path::new(exe)));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod maven_linkage_tests {
|
||||
#[test]
|
||||
|
||||
@@ -352,6 +352,7 @@ async fn restricted_git_views_ignore_project_executables_and_mutations_cannot_ru
|
||||
project.with_repo(|repo| repo.commit("trusted", false, false)).unwrap();
|
||||
assert!(root.join("git-executable.marker").exists());
|
||||
assert!(root.join("git-hook.marker").exists());
|
||||
ide_vcs::set_git_executable(None);
|
||||
host.shutdown().await;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
//! Which git executable each window's repositories run. Its own test binary: the default
|
||||
//! executable (global settings) is process-wide.
|
||||
//! The configured Git binary is process-wide, so it has its own test binary.
|
||||
#![cfg(unix)]
|
||||
use ide_core::NullSink;
|
||||
use ide_host::{Host, HostConfig, ops};
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
fn host(base: &Path) -> Arc<Host> {
|
||||
Arc::new(Host::new(HostConfig {
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn restricted_status_does_not_select_the_project_git_for_other_windows() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let base = dunce::canonicalize(tmp.path()).unwrap();
|
||||
let host = Arc::new(Host::new(HostConfig {
|
||||
config_dir: base.join("config"),
|
||||
data_dir: base.join("data"),
|
||||
local_data_dir: base.join("data"),
|
||||
@@ -18,126 +19,7 @@ fn host(base: &Path) -> Arc<Host> {
|
||||
owner: |w| w,
|
||||
runtime: tokio::runtime::Handle::current(),
|
||||
project_environment: false,
|
||||
}))
|
||||
}
|
||||
|
||||
/// A repository with `tools/git`: it appends a line to `marker`, waits while `gate` exists,
|
||||
/// then runs the real git.
|
||||
fn repo_with_wrapper(root: &Path, marker: &Path, gate: &Path) {
|
||||
std::fs::create_dir_all(root.join(".openidea")).unwrap();
|
||||
std::fs::create_dir_all(root.join("tools")).unwrap();
|
||||
let real = ide_vcs::detected_git_executable().expect("git is installed");
|
||||
let wrapper = root.join("tools/git");
|
||||
let script = format!(
|
||||
"#!/bin/sh\necho run >> '{}'\ni=0\nwhile [ -e '{}' ] && [ $i -lt 400 ]; do sleep 0.05; i=$((i+1)); done\nexec '{}' \"$@\"\n",
|
||||
marker.display(),
|
||||
gate.display(),
|
||||
real.display()
|
||||
);
|
||||
std::fs::write(&wrapper, script).unwrap();
|
||||
std::fs::set_permissions(&wrapper, std::fs::Permissions::from_mode(0o755)).unwrap();
|
||||
let init = std::process::Command::new(&real).arg("init").arg("-q").arg(root).output().unwrap();
|
||||
assert!(init.status.success(), "{}", String::from_utf8_lossy(&init.stderr));
|
||||
}
|
||||
|
||||
fn runs(marker: &Path) -> usize {
|
||||
std::fs::read_to_string(marker).map_or(0, |s| s.lines().count())
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn a_project_git_executable_stays_with_its_project_while_another_window_runs_git() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let base = dunce::canonicalize(tmp.path()).unwrap();
|
||||
let host = host(&base);
|
||||
let (a, c) = (base.join("a"), base.join("c"));
|
||||
let (a_marker, c_marker, gate) = (base.join("a.marker"), base.join("c.marker"), base.join("gate"));
|
||||
repo_with_wrapper(&a, &a_marker, &gate);
|
||||
repo_with_wrapper(&c, &c_marker, &gate);
|
||||
// Relative: resolved against the repository that runs it, so C has a `tools/git` of its own.
|
||||
std::fs::write(a.join(".openidea/settings.toml"), "[vcs.git]\nexecutable = \"tools/git\"\n").unwrap();
|
||||
let project_a = host.open_project("a", &a).unwrap();
|
||||
host.open_project("c", &c).unwrap();
|
||||
for root in [&a, &c] {
|
||||
host.set_project_trust(root, true, false).await.unwrap();
|
||||
}
|
||||
|
||||
// Project A runs two git commands in one go, as `compare_paths` does; window C runs its own
|
||||
// git between them.
|
||||
std::fs::write(&gate, "").unwrap();
|
||||
let two_commands = tokio::task::spawn_blocking(move || {
|
||||
project_a.with_repo(|repo| {
|
||||
repo.remotes()?;
|
||||
repo.remotes()
|
||||
})
|
||||
});
|
||||
for _ in 0..200 {
|
||||
if runs(&a_marker) > 0 {
|
||||
break;
|
||||
}
|
||||
tokio::time::sleep(std::time::Duration::from_millis(50)).await;
|
||||
}
|
||||
assert_eq!(runs(&a_marker), 1, "control: project A's first command runs A's git");
|
||||
ops::vcs::vcs_status(&host, "c").await.unwrap();
|
||||
ops::vcs::vcs_remotes(&host, "c", None).await.unwrap();
|
||||
std::fs::remove_file(&gate).unwrap();
|
||||
two_commands.await.unwrap().unwrap();
|
||||
|
||||
assert_eq!(runs(&a_marker), 2, "project A's second command lost A's git once window C ran git");
|
||||
assert_eq!(runs(&c_marker), 0, "project C has no git setting but ran A's relative tools/git");
|
||||
host.shutdown().await;
|
||||
}
|
||||
|
||||
/// An agent task opens repositories of its own (the project's, then its worktree): their git is
|
||||
/// the project's too.
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn an_agent_task_worktree_runs_the_project_git() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let base = dunce::canonicalize(tmp.path()).unwrap();
|
||||
let host = host(&base);
|
||||
let root = base.join("a");
|
||||
let marker = base.join("a.marker");
|
||||
repo_with_wrapper(&root, &marker, &base.join("no-gate"));
|
||||
let real = ide_vcs::detected_git_executable().unwrap();
|
||||
let commit = std::process::Command::new(&real)
|
||||
.arg("-C")
|
||||
.arg(&root)
|
||||
.args(["-c", "user.name=t", "-c", "[email protected]", "-c", "commit.gpgsign=false"])
|
||||
.args(["commit", "-q", "--allow-empty", "-m", "init"])
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(commit.status.success(), "{}", String::from_utf8_lossy(&commit.stderr));
|
||||
let wrapper = root.join("tools/git");
|
||||
std::fs::write(root.join(".openidea/settings.toml"), format!("[vcs.git]\nexecutable = {wrapper:?}\n")).unwrap();
|
||||
host.open_project("a", &root).unwrap();
|
||||
host.set_project_trust(&root, true, false).await.unwrap();
|
||||
|
||||
let task = ops::agent::agent_create(
|
||||
&host,
|
||||
"a",
|
||||
ide_agent::NewAgentTask {
|
||||
prompt: ide_agent::AgentPrompt { text: "Say hi".into(), ..Default::default() },
|
||||
provider: "codex".into(),
|
||||
isolation: ide_agent::Isolation::Worktree,
|
||||
idle: true,
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert!(task.cwd.0.join(".git").exists(), "the task has its worktree");
|
||||
let created = runs(&marker);
|
||||
assert!(created > 0, "creating the task's worktree ran another git than the project's");
|
||||
|
||||
ops::agent::agent_delete(&host, "a", task.id, true).await.unwrap();
|
||||
assert!(runs(&marker) > created, "removing the task's worktree ran another git than the project's");
|
||||
host.shutdown().await;
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn restricted_status_does_not_select_the_project_git_for_other_windows() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let base = dunce::canonicalize(tmp.path()).unwrap();
|
||||
let host = host(&base);
|
||||
}));
|
||||
let root = base.join("malicious");
|
||||
std::fs::create_dir_all(root.join(".openidea")).unwrap();
|
||||
let marker = base.join("git.marker");
|
||||
|
||||
@@ -249,7 +249,7 @@ async fn restricted_vcs_commands_run_no_program_of_the_repository() {
|
||||
call!("vcs_revision_files", "external", vcs::vcs_revision_files(host, w, log(), external.head.clone())),
|
||||
call!("vcs_commit_files", "external", vcs::vcs_commit_files(host, w, log(), external.head.clone())),
|
||||
// Last: it rewrites nothing of an existing repository, but it does touch it.
|
||||
call!("vcs_init", "", vcs::vcs_init(host, w, project.root.clone())),
|
||||
call!("vcs_init", "", vcs::vcs_init(host, project.root.clone())),
|
||||
];
|
||||
|
||||
// The sweep covers every `vcs_*` command declared `trust = always`: a newly allowed one fails
|
||||
|
||||
@@ -156,8 +156,7 @@ pub struct LanguageServerConfig {
|
||||
pub requires_env: Vec<String>,
|
||||
/// Files whose presence marks a workspace root, e.g. `Cargo.toml`;
|
||||
/// `file#table` requires the TOML file to contain that dotted table, e.g.
|
||||
/// `pyproject.toml#tool.ruff`, or the JSON file that dotted key, e.g.
|
||||
/// `package.json#devDependencies.tailwindcss`.
|
||||
/// `pyproject.toml#tool.ruff`.
|
||||
#[serde(default)]
|
||||
pub root_markers: Vec<String>,
|
||||
/// Serve only files below a root marker, not the whole project: a framework's
|
||||
|
||||
@@ -58,12 +58,11 @@ pub fn arduino_sketch_root(project: &Path, path: &Path) -> Option<PathBuf> {
|
||||
|
||||
/// `dir` contains `marker`: a relative path, a file name pattern with one
|
||||
/// `*` (`*.csproj`), or a TOML or JSON file name (no pattern) and a dotted table
|
||||
/// or JSON key it must contain (`pyproject.toml#tool.ruff`, `package.json#eslintConfig`,
|
||||
/// `package.json#devDependencies.tailwindcss`).
|
||||
/// it must contain (`pyproject.toml#tool.ruff`, `package.json#eslintConfig`).
|
||||
fn has_marker(dir: &Path, marker: &str) -> bool {
|
||||
if let Some((file, table)) = marker.split_once('#') {
|
||||
return if file.ends_with(".json") {
|
||||
has_json_key(&dir.join(file), table)
|
||||
has_json_object(&dir.join(file), table)
|
||||
} else {
|
||||
has_toml_table(&dir.join(file), table)
|
||||
};
|
||||
@@ -89,12 +88,11 @@ fn has_toml_table(file: &Path, table: &str) -> bool {
|
||||
table.split('.').try_fold(&value, |v, key| v.get(key)).is_some_and(toml::Value::is_table)
|
||||
}
|
||||
|
||||
/// `file` parses as JSON and has the dotted `key` with a value other than `null`:
|
||||
/// an object (`eslintConfig`) or a dependency's version (`dependencies.tailwindcss`).
|
||||
fn has_json_key(file: &Path, key: &str) -> bool {
|
||||
/// `file` parses as JSON and has the dotted object `key` (`eslintConfig`).
|
||||
fn has_json_object(file: &Path, key: &str) -> bool {
|
||||
let Ok(text) = std::fs::read_to_string(file) else { return false };
|
||||
let Ok(value) = serde_json::from_str::<serde_json::Value>(&text) else { return false };
|
||||
key.split('.').try_fold(&value, |v, key| v.get(key)).is_some_and(|v| !v.is_null())
|
||||
key.split('.').try_fold(&value, |v, key| v.get(key)).is_some_and(serde_json::Value::is_object)
|
||||
}
|
||||
|
||||
/// `path` is (or, after its creation or removal, was) a root marker of the
|
||||
@@ -179,20 +177,6 @@ mod tests {
|
||||
assert!(!is_marker_path(&root.join("svc/setup.cfg"), "pyproject.toml#tool.ruff"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn json_markers_need_their_key() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let dir = tmp.path();
|
||||
let marker = "package.json#devDependencies.tailwindcss";
|
||||
std::fs::write(dir.join("package.json"), r#"{"devDependencies": {"vite": "^7.0.0"}}"#).unwrap();
|
||||
assert!(!has_marker(dir, marker));
|
||||
std::fs::write(dir.join("package.json"), r#"{"devDependencies": {"tailwindcss": "^4.1.0"}}"#).unwrap();
|
||||
assert!(has_marker(dir, marker) && !has_marker(dir, "package.json#dependencies.tailwindcss"));
|
||||
std::fs::write(dir.join("package.json"), r#"{"eslintConfig": null}"#).unwrap();
|
||||
assert!(!has_marker(dir, "package.json#eslintConfig"));
|
||||
assert!(is_marker_path(&dir.join("package.json"), marker));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn patterns_match_file_names() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -715,20 +715,9 @@ mod tests {
|
||||
// it); before the HTML server (hover, rename and symbols take the first).
|
||||
assert_eq!(
|
||||
names("typescript"),
|
||||
[
|
||||
"vtsls",
|
||||
"typescript-language-server",
|
||||
"angular-language-server",
|
||||
"oxlint",
|
||||
"eslint",
|
||||
"biome",
|
||||
"tailwindcss-language-server"
|
||||
]
|
||||
);
|
||||
assert_eq!(
|
||||
names("html"),
|
||||
["angular-language-server", "vscode-html-language-server", "tailwindcss-language-server"]
|
||||
["vtsls", "typescript-language-server", "angular-language-server", "oxlint", "eslint"]
|
||||
);
|
||||
assert_eq!(names("html"), ["angular-language-server", "vscode-html-language-server"]);
|
||||
for lang in ["typescript", "html"] {
|
||||
let cfg = reg.get(&LanguageId::new(lang)).unwrap();
|
||||
let angular = cfg.language_servers.iter().find(|s| s.name == "angular-language-server").unwrap();
|
||||
@@ -755,34 +744,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn biome_lints_files_below_its_config_or_installation() {
|
||||
let reg = reg();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let root = tmp.path();
|
||||
for dir in ["apps/web/src", "apps/admin/node_modules/@biomejs/biome", "apps/api"] {
|
||||
std::fs::create_dir_all(root.join(dir)).unwrap();
|
||||
}
|
||||
std::fs::write(root.join("apps/web/biome.jsonc"), "{}").unwrap();
|
||||
for lang in
|
||||
["javascript", "javascriptreact", "typescript", "typescriptreact", "json", "jsonc", "css", "graphql"]
|
||||
{
|
||||
let cfg = reg.get(&LanguageId::new(lang)).unwrap();
|
||||
let biome = cfg.language_servers.iter().find(|s| s.name == "biome").unwrap();
|
||||
assert_eq!(
|
||||
(biome.command.as_str(), biome.args.as_slice()),
|
||||
("biome", ["lsp-proxy".to_string()].as_slice())
|
||||
);
|
||||
assert!(biome.require_root_marker && !biome.fallback, "{lang}");
|
||||
// Reformat Code runs `biome format`: the server's formatting would race the language's own.
|
||||
assert_eq!(biome.features, ["code-action", "diagnostics"], "{lang}");
|
||||
let served = |file: &str| crate::marked_root(Some(root), &root.join(file), &biome.root_markers);
|
||||
assert_eq!(served("apps/web/src/main.ts"), Some(root.join("apps/web")), "{lang}");
|
||||
assert_eq!(served("apps/admin/main.ts"), Some(root.join("apps/admin")), "{lang}");
|
||||
assert_eq!(served("apps/api/main.ts"), None, "{lang}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eslint_serves_js_files_only_below_its_config() {
|
||||
let reg = reg();
|
||||
@@ -810,60 +771,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tailwind_serves_web_files_only_in_tailwind_projects() {
|
||||
let reg = reg();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let root = tmp.path();
|
||||
for dir in ["v3/src", "v4/src", "plain/src"] {
|
||||
std::fs::create_dir_all(root.join(dir)).unwrap();
|
||||
}
|
||||
std::fs::write(root.join("v3/tailwind.config.js"), "module.exports = {};").unwrap();
|
||||
std::fs::write(root.join("v4/package.json"), r#"{"devDependencies": {"tailwindcss": "^4.1.0"}}"#).unwrap();
|
||||
std::fs::write(root.join("plain/package.json"), r#"{"devDependencies": {"vite": "^7.0.0"}}"#).unwrap();
|
||||
for lang in
|
||||
["html", "css", "javascript", "javascriptreact", "typescript", "typescriptreact", "vue", "svelte", "astro"]
|
||||
{
|
||||
let cfg = reg.get(&LanguageId::new(lang)).unwrap();
|
||||
// Last: the language's own servers answer hover first.
|
||||
let tailwind = cfg.language_servers.last().unwrap();
|
||||
assert_eq!(tailwind.name, "tailwindcss-language-server", "{lang}");
|
||||
assert_eq!(tailwind.args, ["--stdio"], "{lang}");
|
||||
assert!(tailwind.require_root_marker && !tailwind.fallback, "{lang}");
|
||||
let served = |file: &str| crate::marked_root(Some(root), &root.join(file), &tailwind.root_markers);
|
||||
assert_eq!(served("v3/src/app.css"), Some(root.join("v3")), "{lang}");
|
||||
assert_eq!(served("v4/src/app.css"), Some(root.join("v4")), "{lang}");
|
||||
assert_eq!(served("plain/src/app.css"), None, "{lang}: package.json without tailwindcss");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stylelint_serves_style_sheets_only_below_its_config() {
|
||||
let reg = reg();
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let root = tmp.path();
|
||||
for dir in ["apps/web/src", "apps/admin/src", "apps/api"] {
|
||||
std::fs::create_dir_all(root.join(dir)).unwrap();
|
||||
}
|
||||
std::fs::write(root.join("apps/web/stylelint.config.mjs"), "export default {};").unwrap();
|
||||
std::fs::write(root.join("apps/admin/package.json"), r#"{"stylelint": {"extends": []}}"#).unwrap();
|
||||
std::fs::write(root.join("apps/api/package.json"), r#"{"name": "api"}"#).unwrap();
|
||||
for lang in ["css", "scss", "less"] {
|
||||
let cfg = reg.get(&LanguageId::new(lang)).unwrap();
|
||||
let stylelint = cfg.language_servers.iter().find(|s| s.name == "stylelint").unwrap();
|
||||
assert_eq!(stylelint.command, "stylelint-language-server", "{lang}");
|
||||
assert!(stylelint.require_root_marker && !stylelint.fallback, "{lang}");
|
||||
assert_eq!(stylelint.features, ["code-action", "diagnostics"], "{lang}");
|
||||
// The server lints only the languages in `validate` (CSS alone by default).
|
||||
let validate = stylelint.settings.as_ref().unwrap().get("validate").unwrap();
|
||||
assert_eq!(validate, &serde_json::json!(["css", "scss", "less"]), "{lang}");
|
||||
let served = |file: &str| crate::marked_root(Some(root), &root.join(file), &stylelint.root_markers);
|
||||
assert_eq!(served("apps/web/src/app.css"), Some(root.join("apps/web")), "{lang}");
|
||||
assert_eq!(served("apps/admin/src/app.css"), Some(root.join("apps/admin")), "{lang}");
|
||||
assert_eq!(served("apps/api/app.css"), None, "{lang}: package.json without stylelint");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn laravel_lsp_serves_php_files_only_below_artisan() {
|
||||
let reg = reg();
|
||||
|
||||
@@ -21,7 +21,6 @@ const GENERATED_SOURCES: &str = "openidea.java.generatedSources";
|
||||
|
||||
pub(crate) mod configuration;
|
||||
pub(crate) mod exception_breakpoints;
|
||||
mod exception_type;
|
||||
mod extract_interface;
|
||||
mod formatter;
|
||||
mod generated;
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
//! The exception class at a caret, for the exception breakpoint intention, through the
|
||||
//! app-owned JDT extension (`java/java-usages`).
|
||||
use super::COMMAND_TIMEOUT;
|
||||
use crate::LspManager;
|
||||
use crate::types::ExceptionClassRef;
|
||||
use ide_core::{CancellationToken, DocId, IdeError, IdeResult, Pos};
|
||||
use serde_json::json;
|
||||
|
||||
const EXCEPTION_TYPE: &str = "openidea.java.exceptionType";
|
||||
|
||||
impl LspManager {
|
||||
/// The Throwable class the caret at `pos` names; `None` when there is none, or when no
|
||||
/// server of the document has the command.
|
||||
pub async fn exception_class_at(
|
||||
&self,
|
||||
doc: DocId,
|
||||
pos: Pos,
|
||||
cancel: CancellationToken,
|
||||
) -> IdeResult<Option<ExceptionClassRef>> {
|
||||
let snap = self.snapshot(doc)?;
|
||||
let mut targets = self.ready_targets(&snap.servers, |c| c.commands().iter().any(|c| c == EXCEPTION_TYPE)).await;
|
||||
if targets.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
let t = targets.swap_remove(0);
|
||||
let at = snap.position(&t, pos);
|
||||
let params = json!({
|
||||
"command": EXCEPTION_TYPE,
|
||||
"arguments": [snap.uri, at.line, at.character],
|
||||
});
|
||||
let found: Option<ExceptionClassRef> =
|
||||
self.call(&t, "workspace/executeCommand", params, Some(&cancel), COMMAND_TIMEOUT).await?;
|
||||
if cancel.is_cancelled() {
|
||||
return Err(IdeError::cancelled());
|
||||
}
|
||||
Ok(found)
|
||||
}
|
||||
}
|
||||
@@ -467,16 +467,6 @@ pub struct HierarchyMember {
|
||||
pub abstractable: bool,
|
||||
}
|
||||
|
||||
/// The exception class a caret names: a reference to it, its declaration, or a throw of it.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ExceptionClassRef {
|
||||
/// The binary name (`app.Outer$Failure`), as exception breakpoints take it.
|
||||
pub qualified_name: String,
|
||||
/// The simple name (`Failure`).
|
||||
pub display_name: String,
|
||||
}
|
||||
|
||||
/// The class at a position and what can move: pull-up destinations, or the subclasses
|
||||
/// members are pushed into.
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Type)]
|
||||
|
||||
@@ -3770,36 +3770,6 @@ async fn exception_breakpoints_send_the_whole_list_and_decode_states() {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn exception_class_at_asks_the_extension_and_is_none_without_it() {
|
||||
let mut caps = incremental_caps();
|
||||
caps["executeCommandProvider"] = json!({"commands": ["openidea.java.exceptionType"]});
|
||||
let h = harness_for("java", "java", &[("jdtls", caps)], &[]);
|
||||
let (doc, path) = h.open("Main.java", "class Main {\n void f() { throw new Failure(); }\n}");
|
||||
h.wait_status("jdtls", ServerStatus::Ready).await;
|
||||
let s = h.launcher.state("jdtls");
|
||||
s.respond("workspace/executeCommand", json!({"qualifiedName": "app.Main$Failure", "displayName": "Failure"}));
|
||||
let found = h.mgr.exception_class_at(doc, Pos::new(1, 23), Default::default()).await.unwrap();
|
||||
assert_eq!(
|
||||
found,
|
||||
Some(ide_lsp::types::ExceptionClassRef {
|
||||
qualified_name: "app.Main$Failure".into(),
|
||||
display_name: "Failure".into()
|
||||
})
|
||||
);
|
||||
let asked = s.requested("workspace/executeCommand");
|
||||
assert_eq!(asked[0]["command"], "openidea.java.exceptionType");
|
||||
assert_eq!(asked[0]["arguments"], json!([uri_of(&path), 1, 23]));
|
||||
s.respond("workspace/executeCommand", json!(null));
|
||||
assert_eq!(h.mgr.exception_class_at(doc, Pos::new(0, 1), Default::default()).await.unwrap(), None);
|
||||
|
||||
let plain = harness_for("java", "java", &[("jdtls", incremental_caps())], &[]);
|
||||
let (doc, _) = plain.open("Main.java", "class Main {}");
|
||||
plain.wait_status("jdtls", ServerStatus::Ready).await;
|
||||
assert_eq!(plain.mgr.exception_class_at(doc, Pos::new(0, 7), Default::default()).await.unwrap(), None);
|
||||
assert!(plain.launcher.state("jdtls").requested("workspace/executeCommand").is_empty());
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn debug_server_port_maps_to_module() {
|
||||
let h = harness_for("java", "java", &[("jdtls", incremental_caps())], &[]);
|
||||
|
||||
@@ -947,73 +947,6 @@ async fn angular_language_server_end_to_end() {
|
||||
tokio::time::timeout(Duration::from_secs(10), mgr.shutdown_all()).await.unwrap();
|
||||
}
|
||||
|
||||
/// The Tailwind CSS server on `fixtures/tailwind-app` (Tailwind 4, `@theme` colours), with
|
||||
/// the built-in definitions: class completion in JSX and `@apply`, hover with the generated
|
||||
/// CSS, and the class conflict warning. Set `OPENIDEA_TEST_NPM_TOOLS` to a dir with
|
||||
/// `npm i @tailwindcss/language-server`; the fixture's own `tailwindcss` isn't needed.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
#[ignore = "requires @tailwindcss/language-server (OPENIDEA_TEST_NPM_TOOLS)"]
|
||||
async fn tailwindcss_language_server_end_to_end() {
|
||||
let tools = std::path::PathBuf::from(std::env::var("OPENIDEA_TEST_NPM_TOOLS").expect("OPENIDEA_TEST_NPM_TOOLS"));
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let root = dir.path().canonicalize().unwrap();
|
||||
let fixture = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../fixtures/tailwind-app");
|
||||
for file in ["package.json", "index.html", "src/app.css", "src/App.tsx"] {
|
||||
std::fs::create_dir_all(root.join(file).parent().unwrap()).unwrap();
|
||||
std::fs::copy(fixture.join(file), root.join(file)).unwrap();
|
||||
}
|
||||
let builtin = LanguageRegistry::load(None).unwrap();
|
||||
let languages = ["typescriptreact", "css"].map(|id| {
|
||||
let mut cfg = builtin.get(&LanguageId::new(id)).unwrap();
|
||||
cfg.language_servers.retain(|s| s.name == "tailwindcss-language-server");
|
||||
let bin = tools.join("node_modules/.bin/tailwindcss-language-server");
|
||||
cfg.language_servers[0].command = bin.to_string_lossy().into_owned();
|
||||
cfg
|
||||
});
|
||||
let (mgr, events) = manager(&root, LanguageRegistry::from_configs(languages.to_vec()));
|
||||
let (tsx, css) = (DocId::next(), DocId::next());
|
||||
let tsx_path = root.join("src/App.tsx");
|
||||
let css_path = root.join("src/app.css");
|
||||
let tsx_text = std::fs::read_to_string(&tsx_path).unwrap();
|
||||
let css_text = std::fs::read_to_string(&css_path).unwrap();
|
||||
mgr.did_open(tsx, &tsx_path, &LanguageId::new("typescriptreact"), 1, &tsx_text);
|
||||
mgr.did_open(css, &css_path, &LanguageId::new("css"), 1, &css_text);
|
||||
let at = |text: &str, needle: &str, offset: usize| {
|
||||
let (line, l) = text.lines().enumerate().find(|(_, l)| l.contains(needle)).unwrap();
|
||||
Pos::new(line as u32, (l.find(needle).unwrap() + offset) as u32)
|
||||
};
|
||||
|
||||
// The project's own `@theme` colour, in `className` and after `@apply`.
|
||||
let in_class = at(&tsx_text, "className=\"flex flex-col", "className=\"".len());
|
||||
let in_apply = at(&css_text, "@apply rounded-md", "@apply ".len());
|
||||
for (doc, pos) in [(tsx, in_class), (css, in_apply)] {
|
||||
retry("class completion", Duration::from_secs(60), || {
|
||||
let mgr = mgr.clone();
|
||||
async move {
|
||||
let list = mgr.completion(doc, pos, None, Default::default()).await.ok()?;
|
||||
list.items.iter().any(|i| i.label == "bg-brand-500").then_some(())
|
||||
}
|
||||
})
|
||||
.await;
|
||||
}
|
||||
let hover = mgr.hover(tsx, at(&tsx_text, "bg-white", 1), Default::default()).await.unwrap().unwrap();
|
||||
assert!(hover.contents.value.contains("background-color"), "{}", hover.contents.value);
|
||||
let hover = mgr.hover(tsx, at(&tsx_text, "text-brand-700", 1), Default::default()).await.unwrap().unwrap();
|
||||
assert!(hover.contents.value.contains("--color-brand-700"), "{}", hover.contents.value);
|
||||
|
||||
// `flex block`: both set `display`.
|
||||
retry("class conflict", Duration::from_secs(30), || {
|
||||
let found = events.lock().iter().any(|e| {
|
||||
matches!(e, IdeEvent::Diagnostics { path, items, .. }
|
||||
if path.ends_with("src/App.tsx")
|
||||
&& items.iter().any(|d| d.message.contains("applies the same CSS properties")))
|
||||
});
|
||||
async move { found.then_some(()) }
|
||||
})
|
||||
.await;
|
||||
tokio::time::timeout(Duration::from_secs(10), mgr.shutdown_all()).await.unwrap();
|
||||
}
|
||||
|
||||
/// A notebook's code cells on basedpyright and Ruff (LSP 3.17 notebook sync): names flow from
|
||||
/// earlier cells, IPython magics parse, and locations and diagnostics name the cells.
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
|
||||
@@ -244,16 +244,13 @@ pub(crate) fn is_test_script(name: &str) -> bool {
|
||||
}
|
||||
|
||||
/// The test runner a `package.json` script starts, when its output and test selection differ
|
||||
/// from Jest / Vitest's: `playwright test`, `mocha`, or `node --test` (`tsx --test`) with Node's own
|
||||
/// from Jest / Vitest's: `playwright test`, or `node --test` (`tsx --test`) with Node's own
|
||||
/// reporters (the IDE adds its reporter next to them, which a reporter chosen here would clash with).
|
||||
fn script_test_runner(script: &str) -> Option<&'static str> {
|
||||
let tokens: Vec<&str> = script.split(|c: char| c.is_whitespace() || matches!(c, '&' | '|' | ';')).collect();
|
||||
if tokens.windows(2).any(|w| w[0] == "playwright" && w[1] == "test") {
|
||||
return Some("playwright");
|
||||
}
|
||||
if tokens.iter().any(|t| matches!(t.rsplit('/').next(), Some("mocha" | "_mocha"))) {
|
||||
return Some("mocha");
|
||||
}
|
||||
let node = tokens.iter().position(|t| matches!(*t, "node" | "tsx"))?;
|
||||
// Node's own options: up to the script (`node server.js --test` passes `--test` to the program).
|
||||
let mut options = Vec::new();
|
||||
|
||||
@@ -92,20 +92,6 @@ fn node_test_scripts() {
|
||||
assert_eq!(find(&c, "npm:start").extras.test_runner, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mocha_scripts() {
|
||||
let dir = project(&[(
|
||||
"package.json",
|
||||
r#"{"scripts":{"spec":"mocha --recursive","test":"nyc ./node_modules/.bin/mocha","lint":"eslint mocha.config.js"}}"#,
|
||||
)]);
|
||||
let c = detect(dir.path());
|
||||
let spec = find(&c, "npm:spec");
|
||||
assert!(spec.is_test);
|
||||
assert_eq!(spec.extras.test_runner.as_deref(), Some("mocha"));
|
||||
assert_eq!(find(&c, "npm:test").extras.test_runner.as_deref(), Some("mocha"));
|
||||
assert!(!find(&c, "npm:lint").is_test);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn package_manager_selection() {
|
||||
for (lock, pm) in [("yarn.lock", "yarn"), ("bun.lockb", "bun"), ("bun.lock", "bun"), ("package-lock.json", "npm")] {
|
||||
|
||||
@@ -6,7 +6,6 @@ edition.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[dependencies]
|
||||
dirs.workspace = true
|
||||
dunce.workspace = true
|
||||
ignore.workspace = true
|
||||
ide-core.workspace = true
|
||||
|
||||
@@ -537,42 +537,6 @@ pub fn configure_gradle_runtime(cfg: &mut LanguageServerConfig, root: &Path, bui
|
||||
merge(cfg.settings.get_or_insert_with(|| json!({})), json!({"java": {"import": {"gradle": gradle}}}));
|
||||
}
|
||||
|
||||
/// Gradle's Eclipse model, which jdtls imports the build through, leaves out project dependencies
|
||||
/// a source set only compiles against (`compileOnly(project(":a"))`) and marks some as test-only,
|
||||
/// so their classes don't resolve in the editor although Gradle compiles. jdtls's Gradle import
|
||||
/// runs an init script that adds them, written to the first of `dirs` whose path has no
|
||||
/// whitespace: Buildship stores the import's arguments joined by spaces and splits them again,
|
||||
/// so `Application Support` would break the path. The name carries the script's hash, so
|
||||
/// releases running side by side never overwrite each other's script.
|
||||
pub fn configure_gradle_classpath(cfg: &mut LanguageServerConfig, dirs: &[PathBuf]) {
|
||||
const SCRIPT: &str = include_str!("gradle-classpath.init.gradle");
|
||||
if cfg.name != "jdtls" {
|
||||
return;
|
||||
}
|
||||
let mut hash = 0xcbf29ce484222325u64;
|
||||
for byte in SCRIPT.bytes() {
|
||||
hash = (hash ^ u64::from(byte)).wrapping_mul(0x100000001b3);
|
||||
}
|
||||
let name = format!("openidea-classpath-{hash:016x}.init.gradle");
|
||||
let Some(script) = dirs
|
||||
.iter()
|
||||
.map(|dir| dir.join(&name))
|
||||
.filter(|script| !script.to_string_lossy().contains(char::is_whitespace))
|
||||
.find(|script| {
|
||||
std::fs::read(script).ok().as_deref() == Some(SCRIPT.as_bytes())
|
||||
|| script.parent().is_some_and(|dir| std::fs::create_dir_all(dir).is_ok())
|
||||
&& std::fs::write(script, SCRIPT).is_ok()
|
||||
})
|
||||
else {
|
||||
tracing::warn!("no directory without spaces for the Gradle classpath init script: {dirs:?}");
|
||||
return;
|
||||
};
|
||||
merge(
|
||||
cfg.settings.get_or_insert_with(|| json!({})),
|
||||
json!({"java": {"import": {"gradle": {"arguments": ["--init-script", script.to_string_lossy()]}}}}),
|
||||
);
|
||||
}
|
||||
|
||||
/// Settings › Build Tools › Maven › Automatically download sources and Always update
|
||||
/// snapshots → jdtls `java.maven.downloadSources` / `java.maven.updateSnapshots`.
|
||||
pub fn configure_maven_sources(cfg: &mut LanguageServerConfig, s: &Settings) {
|
||||
@@ -1460,14 +1424,6 @@ pub fn configure_server(cfg: &mut LanguageServerConfig, root: &Path, server_root
|
||||
if name == astro::SERVER {
|
||||
astro::configure(cfg, root, server_root, s);
|
||||
}
|
||||
// Biome lints with the project's own version (its configuration follows that version's
|
||||
// schema); an explicit executable setting still wins.
|
||||
if name == "biome"
|
||||
&& cfg.command == "biome"
|
||||
&& let Some(bin) = crate::npm::project_bin("biome", root, server_root)
|
||||
{
|
||||
cfg.command = bin.to_string_lossy().into_owned();
|
||||
}
|
||||
if name == crate::arduino::SERVER {
|
||||
crate::arduino::configure(cfg, root, server_root, s);
|
||||
}
|
||||
@@ -2565,33 +2521,6 @@ mod maven_linkage_tests {
|
||||
assert_eq!(gradle["user"]["home"], resolved("/caches/gradle"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gradle_import_adds_the_projects_a_source_set_compiles_against() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
let spaced = temp.path().join("Application Support").join("gradle");
|
||||
let plain = temp.path().join("cache").join("gradle");
|
||||
let mut cfg = custom_server("jdtls", &LanguageServerSettings::default());
|
||||
cfg.settings = Some(json!({"java": {"import": {"gradle": {"enabled": true}}}}));
|
||||
configure_gradle_classpath(&mut cfg, &[spaced.clone(), plain.clone()]);
|
||||
let gradle = &cfg.settings.as_ref().unwrap()["java"]["import"]["gradle"];
|
||||
assert_eq!(gradle["enabled"], json!(true), "merged, not replaced");
|
||||
let args = gradle["arguments"].as_array().unwrap();
|
||||
assert_eq!(args[0], json!("--init-script"));
|
||||
let script = PathBuf::from(args[1].as_str().unwrap());
|
||||
assert_eq!(script.parent(), Some(plain.as_path()), "Buildship splits arguments at spaces");
|
||||
assert!(!spaced.exists());
|
||||
let text = std::fs::read_to_string(&script).unwrap();
|
||||
assert!(text.contains("compileClasspath") && text.contains("whenMerged"));
|
||||
|
||||
let mut other = custom_server("pyright", &LanguageServerSettings::default());
|
||||
configure_gradle_classpath(&mut other, &[plain]);
|
||||
assert!(other.settings.is_none(), "only jdtls imports Gradle builds");
|
||||
|
||||
let mut nowhere = custom_server("jdtls", &LanguageServerSettings::default());
|
||||
configure_gradle_classpath(&mut nowhere, &[spaced]);
|
||||
assert!(nowhere.settings.is_none(), "no usable directory: the import runs without it");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gradle_import_of_a_gradle_build_runs_on_the_project_jdk_like_the_ides_builds() {
|
||||
let temp = tempfile::tempdir().unwrap();
|
||||
@@ -2814,42 +2743,3 @@ mod conda_activation_tests {
|
||||
assert_eq!(conda_activation(&plain.join("bin").join("python"), "bash", Some(conda), None), None);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod biome_tests {
|
||||
use super::*;
|
||||
|
||||
fn binary(dir: &Path) -> PathBuf {
|
||||
let bin = dir.join(if cfg!(windows) { "biome.cmd" } else { "biome" });
|
||||
std::fs::create_dir_all(dir).unwrap();
|
||||
std::fs::write(&bin, "").unwrap();
|
||||
#[cfg(unix)]
|
||||
std::fs::set_permissions(&bin, std::os::unix::fs::PermissionsExt::from_mode(0o755)).unwrap();
|
||||
bin
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn biome_runs_the_projects_own_biome_unless_an_executable_is_set() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let root = tmp.path().join("project");
|
||||
let web = root.join("apps/web");
|
||||
let configured = |s: &Settings, server_root: &Path| {
|
||||
let mut cfg = custom_server("biome", &LanguageServerSettings::default());
|
||||
cfg.command = "biome".into();
|
||||
configure_server(&mut cfg, &root, server_root, s);
|
||||
PathBuf::from(cfg.command)
|
||||
};
|
||||
let workspace = binary(&root.join("node_modules/.bin"));
|
||||
assert_eq!(configured(&Settings::default(), &web), workspace);
|
||||
let member = binary(&web.join("node_modules/.bin"));
|
||||
assert_eq!(configured(&Settings::default(), &web), member);
|
||||
// Outside the project: not the project's installation.
|
||||
binary(&tmp.path().join("node_modules/.bin"));
|
||||
assert_eq!(configured(&Settings::default(), &tmp.path().join("other")), PathBuf::from("biome"));
|
||||
let custom = binary(&tmp.path().join("custom"));
|
||||
let mut s = Settings::default();
|
||||
s.tools
|
||||
.insert("biome".into(), ide_core::settings::ToolSettings { path: custom.to_string_lossy().into_owned() });
|
||||
assert_eq!(configured(&s, &web), custom);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Astro (Volar) requires a TypeScript language-service library at initialize.
|
||||
|
||||
use crate::apply::{merge_init_options, setting_path, tsdk};
|
||||
use crate::npm::{has_ts_api, own_typescript, package_dir, project_bin};
|
||||
use crate::npm::{has_ts_api, own_typescript, package_dir};
|
||||
use ide_core::settings::Settings;
|
||||
use ide_core::tool_path::{find_command, search_path};
|
||||
use ide_language::LanguageServerConfig;
|
||||
@@ -20,7 +20,10 @@ pub(crate) fn configure(cfg: &mut LanguageServerConfig, root: &Path, server_root
|
||||
// A project's installation wins over managed / global tools. Explicit
|
||||
// executable settings still win, as they do for other language servers.
|
||||
if cfg.command == SERVER
|
||||
&& let Some(bin) = project_bin(SERVER, root, server_root)
|
||||
&& let Some(bin) = server_root
|
||||
.ancestors()
|
||||
.take_while(|dir| dir.starts_with(root))
|
||||
.find_map(|dir| find_command(SERVER, dir.join("node_modules/.bin").as_os_str(), server_root))
|
||||
{
|
||||
cfg.command = bin.to_string_lossy().into_owned();
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
// Gradle's Eclipse model leaves out project dependencies a source set only compiles against
|
||||
// (compileOnly, compileOnlyApi), and marks some as test-only. Add each project the main or test
|
||||
// compile classpath names, so Java code sees the classes it compiles against.
|
||||
allprojects {
|
||||
plugins.withId('java') {
|
||||
apply plugin: 'eclipse'
|
||||
eclipse.classpath.file.whenMerged { classpath ->
|
||||
def projectOf = { dep ->
|
||||
def path
|
||||
try { path = dep.path } catch (MissingPropertyException ignored) { path = dep.dependencyProject.path }
|
||||
rootProject.findProject(path)
|
||||
}
|
||||
def wanted = [:]
|
||||
['testCompileClasspath', 'compileClasspath'].each { name ->
|
||||
def configuration = configurations.findByName(name)
|
||||
if (configuration == null) return
|
||||
configuration.allDependencies.withType(ProjectDependency).each { dep ->
|
||||
def target = projectOf(dep)
|
||||
if (target == null || target == project) return
|
||||
def eclipseName = target.extensions.findByName('eclipse')?.project?.name ?: target.name
|
||||
wanted['/' + eclipseName] = name == 'compileClasspath'
|
||||
}
|
||||
}
|
||||
def existing = classpath.entries.findAll { it instanceof org.gradle.plugins.ide.eclipse.model.ProjectDependency }
|
||||
wanted.each { path, main ->
|
||||
def entry = existing.find { it.path == path }
|
||||
if (entry == null) {
|
||||
entry = new org.gradle.plugins.ide.eclipse.model.ProjectDependency(path)
|
||||
entry.entryAttributes['without_test_code'] = 'true'
|
||||
classpath.entries.add(entry)
|
||||
}
|
||||
if (main) entry.entryAttributes.remove('test')
|
||||
else if (!entry.entryAttributes.containsKey('test')) entry.entryAttributes['test'] = 'true'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1629,7 +1629,7 @@ pub fn usages_bundle(data_dir: &Path) -> Option<PathBuf> {
|
||||
install_bundle(
|
||||
data_dir,
|
||||
"java-usages",
|
||||
"1.17.0",
|
||||
"1.16.0",
|
||||
include_bytes!("../../../java/java-usages/openidea-java-usages.jar"),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -287,8 +287,8 @@ pub fn launch_directly(cfg: &mut LanguageServerConfig) {
|
||||
return;
|
||||
}
|
||||
let Some(script) = script_for(cfg) else { return };
|
||||
let home = jdtls_home(&script);
|
||||
let Some(install) = home.as_deref().and_then(|h| find_install(h, std::env::consts::OS, std::env::consts::ARCH))
|
||||
let Some(install) =
|
||||
jdtls_home(&script).and_then(|h| find_install(&h, std::env::consts::OS, std::env::consts::ARCH))
|
||||
else {
|
||||
return;
|
||||
};
|
||||
@@ -307,60 +307,14 @@ pub fn launch_directly(cfg: &mut LanguageServerConfig) {
|
||||
cfg.launch_error = Some(error);
|
||||
return;
|
||||
}
|
||||
let area = home.as_deref().and_then(|home| configuration_area(home, &cfg.args, dirs::cache_dir()));
|
||||
cfg.args = java_args(&install, jdk.major, &cfg.args);
|
||||
if let Some(area) = area
|
||||
&& let Some(jar) = cfg.args.iter().position(|a| a == "-jar")
|
||||
{
|
||||
cfg.args.insert(jar, format!("-Dosgi.configuration.area={}", area.to_string_lossy()));
|
||||
}
|
||||
cfg.command = java.to_string_lossy().into_owned();
|
||||
}
|
||||
|
||||
/// Equinox extracts bundle files, jdtls's Gradle init scripts among them, into its writable
|
||||
/// configuration area, `<home>/configuration` unless the launch names one. jdtls passes those
|
||||
/// scripts to every Gradle import as `--init-script` arguments, and Buildship stores a build's
|
||||
/// arguments joined by spaces and splits them again. Under a home with spaces (macOS's
|
||||
/// `Application Support`) each import that sets a Gradle JDK, user home or argument then fails
|
||||
/// with "The specified initialization script '…/Application' does not exist". Such a home
|
||||
/// gets an area without spaces in the user's cache directory, one per install.
|
||||
fn configuration_area(home: &Path, args: &[String], cache: Option<PathBuf>) -> Option<PathBuf> {
|
||||
let parsed = split_script_args(args);
|
||||
let named = parsed.jvm.iter().any(|a| a.starts_with("-Dosgi.configuration.area="))
|
||||
|| parsed.rest.iter().any(|a| a == "-configuration");
|
||||
if named || !home.join("configuration").to_string_lossy().contains(char::is_whitespace) {
|
||||
return None;
|
||||
}
|
||||
let mut hash = 0xcbf29ce484222325u64;
|
||||
for byte in home.to_string_lossy().bytes() {
|
||||
hash = (hash ^ u64::from(byte)).wrapping_mul(0x100000001b3);
|
||||
}
|
||||
Some(cache?.join("openidea").join("jdtls-configuration").join(format!("{hash:016x}")))
|
||||
.filter(|area| !area.to_string_lossy().contains(char::is_whitespace))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn a_home_with_spaces_gets_a_configuration_area_without_them() {
|
||||
let cache = Some(PathBuf::from("/cache"));
|
||||
let spaced = Path::new("/Users/me/Library/Application Support/openidea/tools/jdtls");
|
||||
let area = configuration_area(spaced, &[], cache.clone()).unwrap();
|
||||
assert!(area.starts_with("/cache/openidea/jdtls-configuration"));
|
||||
assert_eq!(configuration_area(spaced, &[], cache.clone()), Some(area), "one per install");
|
||||
assert_ne!(
|
||||
configuration_area(Path::new("/opt/My Tools/jdtls"), &[], cache.clone()),
|
||||
configuration_area(spaced, &[], cache.clone())
|
||||
);
|
||||
assert_eq!(configuration_area(Path::new("/opt/jdtls"), &[], cache.clone()), None, "the default is fine");
|
||||
let own = strings(&["--jvm-arg=-Dosgi.configuration.area=/mine"]);
|
||||
assert_eq!(configuration_area(spaced, &own, cache.clone()), None, "the user's area stays");
|
||||
assert_eq!(configuration_area(spaced, &strings(&["-configuration", "/mine"]), cache), None);
|
||||
assert_eq!(configuration_area(spaced, &[], Some(PathBuf::from("/My Cache"))), None);
|
||||
}
|
||||
|
||||
fn strings(args: &[&str]) -> Vec<String> {
|
||||
args.iter().map(|s| s.to_string()).collect()
|
||||
}
|
||||
|
||||
@@ -10,13 +10,6 @@ pub(crate) fn has_ts_api(lib: &Path) -> bool {
|
||||
lib.join("typescript.js").is_file()
|
||||
}
|
||||
|
||||
/// `command` installed in the project: the nearest `node_modules/.bin` from `server_root` up to `root`.
|
||||
pub(crate) fn project_bin(command: &str, root: &Path, server_root: &Path) -> Option<PathBuf> {
|
||||
server_root.ancestors().take_while(|dir| dir.starts_with(root)).find_map(|dir| {
|
||||
ide_core::tool_path::find_command(command, dir.join("node_modules/.bin").as_os_str(), server_root)
|
||||
})
|
||||
}
|
||||
|
||||
/// The native executable of TypeScript 7 (`typescript` 7+, whose `tsc` is native, or
|
||||
/// `@typescript/native-preview`'s `tsgo`), from its package directory or its `lib`.
|
||||
/// These packages have no JavaScript API (`lib/typescript.js`); their platform package
|
||||
|
||||
@@ -62,22 +62,13 @@ fn package_bin(package: &Path, tool: &str) -> IdeResult<PathBuf> {
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
/// Prettier and Ruff format ranges for some languages (`config.range`); oxfmt and Biome format whole files only.
|
||||
/// Prettier and Ruff format ranges for some languages (`config.range`); oxfmt formats whole files only.
|
||||
pub fn supports_range(tool: &str, config: &FormatterConfig) -> bool {
|
||||
matches!(tool, "prettier" | "ruff") && config.range
|
||||
}
|
||||
|
||||
fn is_formatter(tool: &str) -> bool {
|
||||
crate::registry::find(tool)
|
||||
.is_some_and(|t| t.kind == crate::ToolKind::Formatter || matches!(t.name, "ruff" | "biome"))
|
||||
}
|
||||
|
||||
/// The npm package that provides `tool`'s CLI.
|
||||
fn npm_package(tool: &str) -> &str {
|
||||
match tool {
|
||||
"biome" => "@biomejs/biome",
|
||||
_ => tool,
|
||||
}
|
||||
crate::registry::find(tool).is_some_and(|t| t.kind == crate::ToolKind::Formatter || t.name == "ruff")
|
||||
}
|
||||
|
||||
impl Tools {
|
||||
@@ -90,7 +81,7 @@ impl Tools {
|
||||
if !is_formatter(tool) {
|
||||
return Err(IdeError::unavailable(format!("Unknown external formatter: {tool}")));
|
||||
}
|
||||
let package = Path::new("node_modules").join(npm_package(tool));
|
||||
let package = Path::new("node_modules").join(tool);
|
||||
let manifest = package.join("package.json");
|
||||
let (path, node) = if let Some(custom) = custom.filter(|p| p.is_dir()) {
|
||||
(package_bin(custom, tool)?, true)
|
||||
@@ -117,7 +108,7 @@ impl Tools {
|
||||
}
|
||||
|
||||
/// Every tool resolves its configuration itself. Prettier's project configuration
|
||||
/// overrides the editor indentation passed here; oxfmt, Biome and Ruff read their own
|
||||
/// overrides the editor indentation passed here; oxfmt and Ruff read their own
|
||||
/// configuration files. Ruff also discovers the nearest `pyproject.toml`,
|
||||
/// `ruff.toml`, or `.ruff.toml` from the stdin filename.
|
||||
pub fn arguments(
|
||||
@@ -146,12 +137,6 @@ pub fn arguments(
|
||||
}
|
||||
return args;
|
||||
}
|
||||
if tool == "biome" {
|
||||
// Biome finds its `biome.json` and ignore files from the file's path itself.
|
||||
let mut path = OsString::from("--stdin-file-path=");
|
||||
path.push(file);
|
||||
return vec!["format".into(), path];
|
||||
}
|
||||
if tool == "prettier" {
|
||||
let parser = if config.parser == "markdown" && file.extension().is_some_and(|s| s == "mdx") {
|
||||
"mdx"
|
||||
@@ -338,38 +323,6 @@ mod tests {
|
||||
assert!(unknown.message.contains("Unknown external formatter"), "{}", unknown.message);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn biome_runs_the_nearest_biomejs_package_with_the_file_path() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
let package = root.join("node_modules/@biomejs/biome");
|
||||
std::fs::create_dir_all(package.join("bin")).unwrap();
|
||||
std::fs::write(package.join("package.json"), r#"{"bin":{"biome":"bin/biome"}}"#).unwrap();
|
||||
std::fs::write(package.join("bin/biome"), "").unwrap();
|
||||
std::fs::write(root.join(".prettierignore"), "dist").unwrap();
|
||||
let file = root.join("packages/web/src/app.ts");
|
||||
let path = std::env::var_os("PATH").unwrap_or_default();
|
||||
let tools = Tools::with_paths(root.join("tools"), path, crate::platform::Platform::current());
|
||||
|
||||
let command = tools.formatter_command("biome", &file, None).unwrap();
|
||||
let program = Path::new(command.get_program()).file_stem().unwrap().to_string_lossy().into_owned();
|
||||
assert_eq!(program, "node");
|
||||
let script: Vec<_> = command.get_args().collect();
|
||||
assert_eq!(
|
||||
Path::new(&script[0]).components().collect::<Vec<_>>(),
|
||||
package.join("bin/biome").components().collect::<Vec<_>>()
|
||||
);
|
||||
|
||||
let config = FormatterConfig { tool: "prettier".into(), parser: "typescript".into(), range: true };
|
||||
let range =
|
||||
Some(FormatRange { start_offset: 3, end_offset: 9, start_line: 1, start_col: 1, end_line: 1, end_col: 7 });
|
||||
let mut stdin_path = OsString::from("--stdin-file-path=");
|
||||
stdin_path.push(&file);
|
||||
// No Prettier ignore files or indentation: Biome reads its own configuration.
|
||||
assert_eq!(arguments("biome", &config, &file, 4, false, range, None), ["format".into(), stdin_path]);
|
||||
assert!(!supports_range("biome", &config));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ruff_formats_stdin_and_uses_its_config_and_range_flags() {
|
||||
let config = FormatterConfig { tool: "ruff".into(), parser: "python".into(), range: true };
|
||||
|
||||
@@ -201,18 +201,6 @@ pub static TOOLS: &[ToolSpec] = &[
|
||||
needs: NODE,
|
||||
homepage: "https://oxc.rs/docs/guide/usage/linter",
|
||||
},
|
||||
// Linter and formatter: `biome lsp-proxy` lints, and Reformat Code runs `biome format`.
|
||||
ToolSpec {
|
||||
name: "biome",
|
||||
display: "Biome",
|
||||
kind: LanguageServer,
|
||||
commands: &["biome"],
|
||||
method: Method::Npm { packages: &["@biomejs/biome"] },
|
||||
fallback: None,
|
||||
version: ver("biome"),
|
||||
needs: NODE,
|
||||
homepage: "https://biomejs.dev",
|
||||
},
|
||||
ToolSpec {
|
||||
name: "eslint",
|
||||
display: "ESLint Language Server",
|
||||
@@ -224,17 +212,6 @@ pub static TOOLS: &[ToolSpec] = &[
|
||||
homepage: "https://github.com/hrsh7th/vscode-langservers-extracted",
|
||||
needs: NODE,
|
||||
},
|
||||
ToolSpec {
|
||||
name: "stylelint",
|
||||
display: "Stylelint Language Server",
|
||||
kind: LanguageServer,
|
||||
commands: &["stylelint-language-server"],
|
||||
method: Method::Npm { packages: &["@stylelint/language-server"] },
|
||||
fallback: None,
|
||||
version: V,
|
||||
homepage: "https://github.com/stylelint/vscode-stylelint",
|
||||
needs: NODE,
|
||||
},
|
||||
ToolSpec {
|
||||
name: "rust-analyzer",
|
||||
display: "rust-analyzer",
|
||||
@@ -467,18 +444,6 @@ pub static TOOLS: &[ToolSpec] = &[
|
||||
homepage: "https://angular.dev/tools/language-service",
|
||||
needs: &[],
|
||||
},
|
||||
ToolSpec {
|
||||
name: "tailwindcss-language-server",
|
||||
display: "Tailwind CSS Language Server",
|
||||
kind: LanguageServer,
|
||||
commands: &["tailwindcss-language-server"],
|
||||
// Brings Tailwind CSS 3 and 4 for projects whose own `tailwindcss` isn't installed yet.
|
||||
method: Method::Npm { packages: &["@tailwindcss/language-server"] },
|
||||
fallback: None,
|
||||
version: V,
|
||||
homepage: "https://github.com/tailwindlabs/tailwindcss-intellisense",
|
||||
needs: NODE,
|
||||
},
|
||||
ToolSpec {
|
||||
name: "graphql-lsp",
|
||||
display: "GraphQL Language Server",
|
||||
@@ -1321,7 +1286,7 @@ mod tests {
|
||||
known.insert((d.adapter.clone(), d.command.clone()));
|
||||
}
|
||||
}
|
||||
// The host selects the formatter of each file (Prettier, oxfmt or Biome) and runs its own CLIs.
|
||||
// The host selects the formatter of each file (Prettier or oxfmt) and runs its own CLIs.
|
||||
for t in TOOLS.iter().filter(|t| !matches!(t.kind, Plugin | Formatter | Cli)) {
|
||||
assert!(
|
||||
known.contains(&(t.name.to_string(), t.commands[0].to_string())),
|
||||
|
||||
@@ -13,15 +13,15 @@ use std::time::{Duration, Instant};
|
||||
/// to exit on `SIGTERM` before `SIGKILL`: git removes its `index.lock` on `SIGTERM`.
|
||||
const KILL_GRACE: Duration = Duration::from_millis(20);
|
||||
|
||||
/// Git executable of the user's global settings (`None` = auto-detect). Never a project's: a
|
||||
/// project's repositories carry their own ([`crate::Repo::set_git_executable`]).
|
||||
static DEFAULT: std::sync::RwLock<Option<PathBuf>> = std::sync::RwLock::new(None);
|
||||
/// Explicit git executable from Settings › Version Control › Git (`None` = auto-detect).
|
||||
static CONFIGURED: std::sync::RwLock<Option<PathBuf>> = std::sync::RwLock::new(None);
|
||||
|
||||
/// Sets (or clears, with `None` / an empty path) the git executable of repositories that have
|
||||
/// none of their own, from the global settings only.
|
||||
pub fn set_default_git_executable(path: Option<&Path>) {
|
||||
/// Sets (or clears, with `None` / an empty path) the git executable to use.
|
||||
pub fn set_git_executable(path: Option<&Path>) {
|
||||
let path = path.filter(|p| !p.as_os_str().is_empty()).map(Path::to_path_buf);
|
||||
*DEFAULT.write().unwrap_or_else(|e| e.into_inner()) = path;
|
||||
if *CONFIGURED.read().unwrap_or_else(|e| e.into_inner()) != path {
|
||||
*CONFIGURED.write().unwrap_or_else(|e| e.into_inner()) = path;
|
||||
}
|
||||
}
|
||||
|
||||
/// Environment that routes credential prompts (`ssh` passphrases and host keys,
|
||||
@@ -102,20 +102,16 @@ pub fn detected_git_executable() -> Option<PathBuf> {
|
||||
detected_git().map(Path::to_path_buf)
|
||||
}
|
||||
|
||||
/// The executable of the repository this thread works in, else the default, else the detected one.
|
||||
pub(crate) fn git_binary() -> IdeResult<PathBuf> {
|
||||
if let Some(own) = crate::scoped_git_executable() {
|
||||
return Ok(own.to_path_buf());
|
||||
}
|
||||
if let Some(default) = DEFAULT.read().unwrap_or_else(|e| e.into_inner()).clone() {
|
||||
return Ok(default);
|
||||
if let Some(configured) = CONFIGURED.read().unwrap_or_else(|e| e.into_inner()).clone() {
|
||||
return Ok(configured);
|
||||
}
|
||||
detected_git()
|
||||
.map(Path::to_path_buf)
|
||||
.ok_or_else(|| IdeError::unavailable("git executable not found; install git and make sure it is on PATH"))
|
||||
}
|
||||
|
||||
/// `git --version` of `executable` (or the default / detected one), e.g. `git version 2.44.0`.
|
||||
/// `git --version` of `executable` (or the configured / detected one), e.g. `git version 2.44.0`.
|
||||
pub fn git_version(executable: Option<&Path>) -> IdeResult<String> {
|
||||
let exe = match executable.filter(|p| !p.as_os_str().is_empty()) {
|
||||
Some(p) => p.to_path_buf(),
|
||||
|
||||
@@ -129,7 +129,8 @@ impl Repos {
|
||||
continue;
|
||||
}
|
||||
let repo = self.at_root(&root.0).expect("scope comes from registry");
|
||||
let _scope = repo.execution_scope();
|
||||
let _scope =
|
||||
crate::ExecutionScope::enter(repo.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let mut missing_revision = false;
|
||||
let mut compare = || -> IdeResult<(String, Vec<WorkingTreeChange>)> {
|
||||
// Worktree comparisons must not run repository-defined clean/process filters
|
||||
|
||||
+102
-153
@@ -700,7 +700,7 @@ mod write;
|
||||
pub use backend::Backend;
|
||||
pub use cli::{
|
||||
GitCommandObserver, detected_git_executable, filter_overrides_from, git_version, restrict, set_askpass_env,
|
||||
set_default_git_executable, set_git_command_observer,
|
||||
set_git_command_observer, set_git_executable,
|
||||
};
|
||||
pub use diff::build_partial_patch;
|
||||
pub use external_diff::{ExternalDiffSide, launch_external_diff};
|
||||
@@ -774,7 +774,7 @@ mod clone_tests {
|
||||
/// Creates an empty repository in `dir` (`git init`).
|
||||
pub fn init(dir: &Path) -> IdeResult<()> {
|
||||
// `git init` runs nothing a repository config names, so the configured git runs as it is.
|
||||
let _scope = ExecutionScope::enter_with(true, opening_git_executable());
|
||||
let _scope = ExecutionScope::enter(true);
|
||||
cli::run(dir, &["init", "-q"], None).map(|_| ())
|
||||
}
|
||||
|
||||
@@ -788,7 +788,6 @@ pub fn diff_hunks(old_text: &str, new_text: &str) -> Vec<LineHunk> {
|
||||
/// on-disk state, so it never needs to be reopened after external changes.
|
||||
pub struct Repo {
|
||||
execution_allowed: std::sync::atomic::AtomicBool,
|
||||
git_executable: std::sync::RwLock<Option<std::sync::Arc<Path>>>,
|
||||
root: PathBuf,
|
||||
git_dir: PathBuf,
|
||||
inner: std::sync::Mutex<repo::Cache>,
|
||||
@@ -807,18 +806,18 @@ impl Repo {
|
||||
}
|
||||
/// The worktree root.
|
||||
pub fn root(&self) -> &Path {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
&self.root
|
||||
}
|
||||
/// git's own folders for this worktree: its git dir and the common one (they differ for a
|
||||
/// linked worktree, whose `.git` file points into the main repository).
|
||||
pub fn metadata_dirs(&self) -> IdeResult<[PathBuf; 2]> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
Ok([self.git_dir.clone(), repo::absolute(self.gix()?.common_dir())?])
|
||||
}
|
||||
/// Untracked files with one of these names (or under such a folder) are not reported.
|
||||
pub fn set_ignored_names(&self, names: IgnoredNames) {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
*self.ignored.write().unwrap_or_else(|p| p.into_inner()) = names;
|
||||
}
|
||||
/// Read the working-tree status with `git status` rather than in process: for file systems
|
||||
@@ -829,13 +828,13 @@ impl Repo {
|
||||
/// Staged (HEAD↔index) and unstaged (index↔worktree, incl. untracked) changes,
|
||||
/// sorted by path. Conflicted files report `unstaged: Conflicted` and no staged kind.
|
||||
pub fn status(&self) -> IdeResult<Vec<FileStatus>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
status::status(self)
|
||||
}
|
||||
/// Status of `paths` only (absolute; those outside the repository are ignored), for the
|
||||
/// dirty-scope refresh after a watcher batch. An empty list is the full status.
|
||||
pub fn status_paths(&self, paths: &[PathBuf]) -> IdeResult<Vec<FileStatus>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
// Restricted Mode starts no program of the repository, and the scoped read is `git status`
|
||||
// with a pathspec: answer with the full gitoxide status instead.
|
||||
if !self.execution_allowed.load(std::sync::atomic::Ordering::Acquire) {
|
||||
@@ -851,18 +850,18 @@ impl Repo {
|
||||
status::status_paths(self, &rel)
|
||||
}
|
||||
pub fn branch_info(&self) -> IdeResult<BranchInfo> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
refs::branch_info(self)
|
||||
}
|
||||
/// Current branch (short name; `None` when detached) and HEAD commit, without
|
||||
/// upstream tracking (cheap enough to call for every repository on each refresh).
|
||||
pub fn head(&self) -> IdeResult<(Option<String>, Option<String>)> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
refs::head(&self.gix()?)
|
||||
}
|
||||
/// Merge / rebase / cherry-pick… in progress (cheap: no ref walking).
|
||||
pub fn operation(&self) -> IdeResult<Option<String>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
Ok(refs::operation(&self.gix()?))
|
||||
}
|
||||
/// Content of `path` at `rev` (default HEAD); `None` if absent there.
|
||||
@@ -874,13 +873,13 @@ impl Repo {
|
||||
encoding: impl Into<TextEncoding>,
|
||||
) -> IdeResult<Option<String>> {
|
||||
let encoding = encoding.into();
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
Ok(self.blob_of(path, rev.unwrap_or("HEAD"))?.map(|b| text_encoding::decode(&b, encoding).into_owned()))
|
||||
}
|
||||
/// The file's git mode at `rev` as printed by git (`100644`, `100755`, `120000`…),
|
||||
/// `None` when absent there. `rev` follows `file_at`'s rules, `WT` reads the worktree.
|
||||
pub fn file_mode_at(&self, path: &Path, rev: Option<&str>) -> IdeResult<Option<String>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
if rev == Some("WT") {
|
||||
return repo::worktree_mode(self.root(), &self.rel_path(path)?);
|
||||
}
|
||||
@@ -890,7 +889,7 @@ impl Repo {
|
||||
}
|
||||
/// Raw revision bytes, for encoding detection when the working file is absent.
|
||||
pub fn file_bytes_at(&self, path: &Path, rev: Option<&str>) -> IdeResult<Option<Vec<u8>>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
self.blob_of(path, rev.unwrap_or("HEAD"))
|
||||
}
|
||||
/// Stage selected decoded hunks, retaining the index encoding, BOM and line endings.
|
||||
@@ -902,7 +901,7 @@ impl Repo {
|
||||
encoding: impl Into<TextEncoding>,
|
||||
) -> IdeResult<()> {
|
||||
let encoding = encoding.into();
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::stage_hunks(self, path, current, selected, encoding)
|
||||
}
|
||||
/// Hunks of `current_text` against HEAD (or the index when `against_index`).
|
||||
@@ -919,7 +918,7 @@ impl Repo {
|
||||
encoding: impl Into<TextEncoding>,
|
||||
) -> IdeResult<Vec<LineHunk>> {
|
||||
let encoding = encoding.into();
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let Ok(rel) = self.rel_path(path) else { return Ok(Vec::new()) };
|
||||
if rel.is_empty() || rel == ".git" || rel.starts_with(".git/") {
|
||||
return Ok(Vec::new());
|
||||
@@ -949,13 +948,13 @@ impl Repo {
|
||||
encoding: impl Into<TextEncoding>,
|
||||
) -> IdeResult<Vec<BlameLine>> {
|
||||
let encoding = encoding.into();
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::blame(self, path, current_text, revision, encoding)
|
||||
}
|
||||
/// Adds `commit` to the list `blame.ignoreRevsFile` names, so annotate skips it; with none
|
||||
/// configured, to `.git-blame-ignore-revs` at the worktree root, which the local config then names.
|
||||
pub fn ignore_blame_revision(&self, commit: &str) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::ignore_blame_revision(self, commit)
|
||||
}
|
||||
/// History for Selection: commits that changed `lines` (0-based, inclusive, of the
|
||||
@@ -969,7 +968,7 @@ impl Repo {
|
||||
cancel: &CancellationToken,
|
||||
) -> IdeResult<BlockHistory> {
|
||||
let encoding = encoding.into();
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
block_history::block_history(self, path, current_text, lines, encoding, cancel)
|
||||
}
|
||||
/// Commits newest-first in topological order (children before parents).
|
||||
@@ -980,11 +979,11 @@ impl Repo {
|
||||
/// `skip`/`limit` paginate over the filtered result; `limit == 0` means no limit.
|
||||
/// `refs` decorations are `HEAD`, branch names (`main`, `origin/main`) and `tag: <name>`.
|
||||
pub fn log(&self, query: &LogQuery) -> IdeResult<Vec<Commit>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
history::log(self, query, &CancellationToken::new())
|
||||
}
|
||||
pub fn log_cancellable(&self, query: &LogQuery, cancel: &CancellationToken) -> IdeResult<Vec<Commit>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
history::log(self, query, cancel)
|
||||
}
|
||||
/// Enables the disposable, content-addressed log cache outside the worktree.
|
||||
@@ -1001,7 +1000,7 @@ impl Repo {
|
||||
.collect())
|
||||
}
|
||||
pub fn log_users(&self) -> IdeResult<Vec<String>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let out = cli::run(self.root(), &["log", "--all", "--format=%an <%ae>"], None)?;
|
||||
Ok(out
|
||||
.stdout_str()
|
||||
@@ -1027,7 +1026,7 @@ impl Repo {
|
||||
cancel: &CancellationToken,
|
||||
) -> IdeResult<Vec<LogDetails>> {
|
||||
let allowed = self.execution_allowed.load(std::sync::atomic::Ordering::Acquire);
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(allowed);
|
||||
let repo = self.gix()?;
|
||||
let shallow: std::collections::HashSet<gix::ObjectId> =
|
||||
repo.shallow_commits().map_err(repo::gx)?.map(|ids| ids.iter().copied().collect()).unwrap_or_default();
|
||||
@@ -1100,7 +1099,7 @@ impl Repo {
|
||||
|
||||
/// Lists one immutable revision directory. Directory names end in `/`.
|
||||
pub fn revision_children(&self, revision: &str, directory: &str) -> IdeResult<Vec<String>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let repo = self.gix()?;
|
||||
let id = repo::resolve(&repo, revision)?.to_string();
|
||||
let directory = self.rel_path(std::path::Path::new(directory))?;
|
||||
@@ -1123,7 +1122,7 @@ impl Repo {
|
||||
}
|
||||
|
||||
pub fn revision_files(&self, revision: &str) -> IdeResult<Vec<String>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let repo = self.gix()?;
|
||||
let id = repo::resolve(&repo, revision)?.to_string();
|
||||
let out = cli::run(self.root(), &["ls-tree", "-r", "-z", "--name-only", "--", &id], None)?;
|
||||
@@ -1136,23 +1135,23 @@ impl Repo {
|
||||
}
|
||||
/// Files changed by `commit` relative to its first parent (renames detected).
|
||||
pub fn commit_files(&self, commit: &str) -> IdeResult<Vec<ChangedFile>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
history::commit_files(self, commit)
|
||||
}
|
||||
/// Combined changes of several commits (oldest first): per file, before the first commit
|
||||
/// that touched it ↔ after the last one (IDEA's multi-commit Git Log selection).
|
||||
pub fn commits_changes(&self, commits: &[String]) -> IdeResult<Vec<RevisionChange>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
history::commits_changes(self, commits)
|
||||
}
|
||||
/// Local and remote branches; the current branch first, then most recent first.
|
||||
pub fn branches(&self) -> IdeResult<Vec<Branch>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
refs::branches(self)
|
||||
}
|
||||
/// Stash entries, newest (`stash@{0}`) first.
|
||||
pub fn stashes(&self) -> IdeResult<Vec<Stash>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
refs::stashes(self)
|
||||
}
|
||||
/// Working tree against a revision, optionally restricted to a file. Bounded and cancellable.
|
||||
@@ -1163,7 +1162,7 @@ impl Repo {
|
||||
max_bytes: usize,
|
||||
cancel: &CancellationToken,
|
||||
) -> IdeResult<String> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let rev = against.unwrap_or("HEAD");
|
||||
if rev.is_empty() || rev.starts_with('-') || rev.contains('\0') {
|
||||
return Err(ide_core::IdeError::invalid("invalid revision"));
|
||||
@@ -1185,13 +1184,13 @@ impl Repo {
|
||||
/// against /dev/null) or HEAD↔index (`staged == true`). Empty when unchanged.
|
||||
pub fn diff_text(&self, path: &Path, staged: bool, encoding: impl Into<TextEncoding>) -> IdeResult<String> {
|
||||
let encoding = encoding.into();
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::diff_text(self, path, staged, encoding)
|
||||
}
|
||||
|
||||
/// `git config --get <key>` (all scopes); `None` when unset.
|
||||
pub fn config_get(&self, key: &str) -> IdeResult<Option<String>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let out = cli::run_raw(&self.root, &["config", "--get", key], None)?;
|
||||
Ok((out.code == Some(0)).then(|| out.stdout_str().trim().to_string()))
|
||||
}
|
||||
@@ -1199,7 +1198,7 @@ impl Repo {
|
||||
/// Sets `user.name` and `user.email` for commits: in this repository's config, or in the
|
||||
/// user's global one (`global`).
|
||||
pub fn set_user_identity(&self, name: &str, email: &str, global: bool) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let scope = if global { "--global" } else { "--local" };
|
||||
for (key, value) in [("user.name", name.trim()), ("user.email", email.trim())] {
|
||||
if value.is_empty() {
|
||||
@@ -1212,11 +1211,11 @@ impl Repo {
|
||||
|
||||
// ---- writes (git CLI) ----
|
||||
pub fn stage(&self, paths: &[PathBuf]) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::stage(self, paths)
|
||||
}
|
||||
pub fn unstage(&self, paths: &[PathBuf]) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::unstage(self, paths)
|
||||
}
|
||||
/// Applies a unified-diff patch to the index (partial staging of hunks/lines).
|
||||
@@ -1226,20 +1225,20 @@ impl Repo {
|
||||
patch: &str,
|
||||
encoding: &dyn Fn(&Path) -> IdeResult<E>,
|
||||
) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::stage_patch(self, patch, &|path| encoding(path).map(Into::into))
|
||||
}
|
||||
/// Discards unstaged changes: tracked paths are restored from the index (staged
|
||||
/// changes are kept), untracked files and directories are deleted. A submodule goes back
|
||||
/// to the commit the index records, with its tracked files restored.
|
||||
pub fn discard(&self, paths: &[PathBuf]) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::discard(self, paths)
|
||||
}
|
||||
/// Commits the index; returns the new HEAD commit id. An empty message with
|
||||
/// `amend` keeps the previous message.
|
||||
pub fn commit(&self, message: &str, amend: bool, sign_off: bool) -> IdeResult<String> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let options = CommitOptions { amend, sign_off, author: None, run_hooks: true, ..Default::default() };
|
||||
write::commit(self, message, &options, &|_| Ok(encoding_rs::UTF_8.into()))
|
||||
}
|
||||
@@ -1250,7 +1249,7 @@ impl Repo {
|
||||
options: &CommitOptions,
|
||||
encoding: &dyn Fn(&Path) -> IdeResult<E>,
|
||||
) -> IdeResult<String> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::commit(self, message, options, &|path| encoding(path).map(Into::into))
|
||||
}
|
||||
/// What [`Repo::commit_with`] would commit with `options`, file by file, without
|
||||
@@ -1261,14 +1260,14 @@ impl Repo {
|
||||
max_bytes: usize,
|
||||
encoding: &dyn Fn(&Path) -> IdeResult<E>,
|
||||
) -> IdeResult<Vec<PendingChange>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::pending_changes(self, options, max_bytes, &|path| encoding(path).map(Into::into))
|
||||
}
|
||||
/// Switches to `branch`. With `create`, creates it at HEAD. Without, a remote branch
|
||||
/// (`origin/x`) gets a local tracking branch and any other revision is checked out
|
||||
/// detached.
|
||||
pub fn checkout(&self, branch: &str, create: bool) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::checkout(self, branch, create)
|
||||
}
|
||||
/// [`Repo::checkout`] as IDEA does it: local changes in the way are reported (or
|
||||
@@ -1276,7 +1275,7 @@ impl Repo {
|
||||
/// is behind fast-forwards that branch, while one that is ahead is reported (or
|
||||
/// rebased / reset per `options.diverged`).
|
||||
pub fn checkout_with(&self, branch: &str, create: bool, options: &CheckoutOptions) -> IdeResult<CheckoutOutcome> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::checkout_with(self, branch, create, options)
|
||||
}
|
||||
/// Creates branch `name` at `start` (default HEAD), optionally switching to it. A
|
||||
@@ -1293,62 +1292,62 @@ impl Repo {
|
||||
checkout: bool,
|
||||
overwrite: bool,
|
||||
) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::create_branch(self, name, start, checkout, overwrite)
|
||||
}
|
||||
/// Undo Commit: resets the current branch to the parent of `commit` (which must be
|
||||
/// HEAD and not a merge) keeping its changes staged; undoing the initial commit
|
||||
/// leaves an unborn branch. Returns the undone commit's message.
|
||||
pub fn undo_commit(&self, commit: &str) -> IdeResult<String> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::undo_commit(self, commit)
|
||||
}
|
||||
/// Deletes a local branch (`git branch -d`, `-D` when `force`).
|
||||
/// Edit Commit Message without touching the index or the working tree; returns HEAD
|
||||
/// before and after.
|
||||
pub fn reword(&self, commit: &str, message: &str) -> IdeResult<HeadChange> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::reword(self, commit, message).map(|(before, after)| HeadChange { before, after })
|
||||
}
|
||||
|
||||
/// Undoes a history rewrite: HEAD goes from `after` back to `before`, local changes kept.
|
||||
pub fn restore_head(&self, before: &str, after: &str) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::restore_head(self, before, after)
|
||||
}
|
||||
|
||||
pub fn delete_branch(&self, branch: &str, force: bool) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::delete_branch(self, branch, force)
|
||||
}
|
||||
/// Deletes a local branch as IDEA does: without asking, force-deleting one that is not
|
||||
/// fully merged (reported as `unmerged`), and returning what [`Repo::restore_branch`]
|
||||
/// needs to undo it.
|
||||
pub fn delete_branch_restorable(&self, branch: &str) -> IdeResult<DeletedBranch> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::delete_branch_restorable(self, branch)
|
||||
}
|
||||
/// Recreates a deleted branch at its old tip, with its upstream.
|
||||
pub fn restore_branch(&self, deleted: &DeletedBranch) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::restore_branch(self, deleted)
|
||||
}
|
||||
/// Renames a local branch (`git branch -m`); its upstream configuration moves with it,
|
||||
/// unless `unset_upstream` drops the tracking instead.
|
||||
pub fn rename_branch(&self, from: &str, to: &str, unset_upstream: bool) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::rename_branch(self, from, to, unset_upstream)
|
||||
}
|
||||
/// Merges `branch` into HEAD; local changes are stashed and restored around it. On
|
||||
/// conflicts an error is returned and the repository is left mid-merge
|
||||
/// (`branch_info().operation == Some("merge")`).
|
||||
pub fn merge(&self, branch: &str) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::merge(self, branch)
|
||||
}
|
||||
/// Rebases the current branch onto `onto`; local changes are stashed and restored.
|
||||
pub fn rebase(&self, onto: &str) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::rebase(self, onto)
|
||||
}
|
||||
/// `paths` (absolute) stashes only those files; empty stashes the whole working tree.
|
||||
@@ -1360,23 +1359,23 @@ impl Repo {
|
||||
keep_index: bool,
|
||||
paths: &[PathBuf],
|
||||
) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::stash_push(self, message, include_untracked, keep_index, paths)
|
||||
}
|
||||
/// `reinstate_index`: also restore what was staged when the stash was made.
|
||||
pub fn stash_apply(&self, index: u32, pop: bool, reinstate_index: bool) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::stash_apply(self, index, pop, reinstate_index)
|
||||
}
|
||||
/// Creates and checks out `branch` at the commit the stash was made on, applies the
|
||||
/// stash there (index included) and drops it.
|
||||
pub fn stash_branch(&self, index: u32, branch: &str) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::stash_branch(self, index, branch)
|
||||
}
|
||||
/// Removes `stash@{index}` without applying it.
|
||||
pub fn stash_drop(&self, index: u32) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::stash_drop(self, index)
|
||||
}
|
||||
/// Deletes a branch on a remote (`git push <remote> --delete <branch>`); `branch` is the
|
||||
@@ -1387,19 +1386,19 @@ impl Repo {
|
||||
cancel: &CancellationToken,
|
||||
on_output: &dyn Fn(String),
|
||||
) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::delete_remote_branch(self, branch, cancel, on_output)
|
||||
}
|
||||
/// Network operations stream progress lines through `on_output`.
|
||||
/// Fetches all remotes (pruning deleted branches).
|
||||
pub fn fetch(&self, cancel: &CancellationToken, on_output: &dyn Fn(String)) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
cli::run_streaming(&self.root, &["fetch", "--progress", "--all", "--prune"], cancel, on_output)
|
||||
}
|
||||
/// Update Project: pulls the upstream by merge or rebase. Local changes are stashed
|
||||
/// and restored; the merge mode fast-forwards when possible whatever `pull.ff` says.
|
||||
pub fn pull(&self, rebase: bool, cancel: &CancellationToken, on_output: &dyn Fn(String)) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let mode: &[&str] = if rebase { &["--rebase"] } else { &["--no-rebase", "--ff"] };
|
||||
let mut args = vec!["pull", "--progress"];
|
||||
args.extend_from_slice(mode);
|
||||
@@ -1436,13 +1435,13 @@ impl Repo {
|
||||
cancel: &CancellationToken,
|
||||
on_output: &dyn Fn(String),
|
||||
) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::push(self, options, cancel, on_output)
|
||||
}
|
||||
/// Whether the repository has an executable hook `name` (e.g. `pre-push`), wherever
|
||||
/// `core.hooksPath` puts it: the Push dialog then offers to skip it.
|
||||
pub fn has_hook(&self, name: &str) -> IdeResult<bool> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::has_hook(self, name)
|
||||
}
|
||||
/// Pushes a local branch, or its history up to `revision`, to its upstream (Git Log
|
||||
@@ -1455,7 +1454,7 @@ impl Repo {
|
||||
cancel: &CancellationToken,
|
||||
on_output: &dyn Fn(String),
|
||||
) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::push_branch(
|
||||
self,
|
||||
branch,
|
||||
@@ -1474,13 +1473,13 @@ impl Repo {
|
||||
cancel: &CancellationToken,
|
||||
on_output: &dyn Fn(String),
|
||||
) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::push_branch(self, branch, options, cancel, on_output)
|
||||
}
|
||||
/// Update Project › Reset to the Remote Branch: the current branch is moved to its
|
||||
/// freshly fetched tracked branch; local commits are dropped, local changes kept.
|
||||
pub fn reset_to_upstream(&self, cancel: &CancellationToken, on_output: &dyn Fn(String)) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::reset_to_upstream(self, cancel, on_output)
|
||||
}
|
||||
/// Branches › Update Selected: fetches each remote once and fast-forwards every
|
||||
@@ -1491,7 +1490,7 @@ impl Repo {
|
||||
cancel: &CancellationToken,
|
||||
on_output: &dyn Fn(String),
|
||||
) -> IdeResult<Vec<BranchUpdate>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
write::update_branches(self, branches, cancel, on_output)
|
||||
}
|
||||
// ---- in-progress operations, history rewriting, tags ----
|
||||
@@ -1499,21 +1498,21 @@ impl Repo {
|
||||
/// Continues the merge / rebase / cherry-pick / revert in progress; fails while
|
||||
/// conflicts are unresolved.
|
||||
pub fn continue_operation(&self, cancel: &CancellationToken, on_output: &dyn Fn(String)) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::continue_op(self, false, cancel, on_output)
|
||||
}
|
||||
/// Stage and Retry: stages the changes of tracked files, then continues.
|
||||
pub fn stage_and_continue(&self, cancel: &CancellationToken, on_output: &dyn Fn(String)) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::continue_op(self, true, cancel, on_output)
|
||||
}
|
||||
pub fn abort_operation(&self, cancel: &CancellationToken, on_output: &dyn Fn(String)) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::abort_op(self, cancel, on_output)
|
||||
}
|
||||
/// Skips the current commit of a rebase / cherry-pick / revert.
|
||||
pub fn skip_operation(&self, cancel: &CancellationToken, on_output: &dyn Fn(String)) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::skip_op(self, cancel, on_output)
|
||||
}
|
||||
/// Cherry-picks `commits` in order (oldest first). Stops mid-way on conflicts.
|
||||
@@ -1533,12 +1532,12 @@ impl Repo {
|
||||
cancel: &CancellationToken,
|
||||
on_output: &dyn Fn(String),
|
||||
) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::cherry_pick(self, commits, record_origin, cancel, on_output)
|
||||
}
|
||||
/// Reverts `commits` in order (newest first) with git's default messages.
|
||||
pub fn revert(&self, commits: &[String], cancel: &CancellationToken, on_output: &dyn Fn(String)) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::revert(self, commits, cancel, on_output)
|
||||
}
|
||||
/// Interactive rebase of `base..HEAD` (`None`: from the root) following `entries`,
|
||||
@@ -1551,7 +1550,7 @@ impl Repo {
|
||||
cancel: &CancellationToken,
|
||||
on_output: &dyn Fn(String),
|
||||
) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::interactive_rebase(self, base, entries, cancel, on_output)
|
||||
}
|
||||
/// Moves the current branch to `commit` (`git reset --<mode>`).
|
||||
@@ -1562,22 +1561,22 @@ impl Repo {
|
||||
cancel: &CancellationToken,
|
||||
on_output: &dyn Fn(String),
|
||||
) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::reset(self, commit, mode, cancel, on_output)
|
||||
}
|
||||
/// Creates tag `name` on `commit` (annotated when `message` is given).
|
||||
pub fn create_tag(&self, name: &str, commit: &str, message: Option<&str>, force: bool) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::create_tag(self, name, commit, message, force)
|
||||
}
|
||||
/// Deletes a local tag, returning what [`Repo::restore_tag`] needs to undo it.
|
||||
pub fn delete_tag(&self, name: &str) -> IdeResult<DeletedTag> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::delete_tag(self, name)
|
||||
}
|
||||
/// Recreates a deleted tag (annotated ones with their message).
|
||||
pub fn restore_tag(&self, deleted: &DeletedTag) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::restore_tag(self, deleted)
|
||||
}
|
||||
/// Pushes one tag to `remote` (Push Tag › Push to …).
|
||||
@@ -1588,7 +1587,7 @@ impl Repo {
|
||||
cancel: &CancellationToken,
|
||||
on_output: &dyn Fn(String),
|
||||
) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::push_tag(self, tag, remote, false, cancel, on_output)
|
||||
}
|
||||
/// Deletes a tag on `remote` (Delete on Remote, after deleting it locally).
|
||||
@@ -1599,33 +1598,33 @@ impl Repo {
|
||||
cancel: &CancellationToken,
|
||||
on_output: &dyn Fn(String),
|
||||
) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::push_tag(self, tag, remote, true, cancel, on_output)
|
||||
}
|
||||
pub fn tags(&self) -> IdeResult<Vec<String>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::tags(self)
|
||||
}
|
||||
/// Files that differ between revisions `from` and `to`.
|
||||
pub fn diff_revisions(&self, from: &str, to: &str) -> IdeResult<Vec<ChangedFile>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::diff_revisions(self, from, to)
|
||||
}
|
||||
/// Added and deleted lines between `from` and `to`. `paths` limits the diff to those
|
||||
/// repository-relative paths (both names of a rename); empty diffs every file.
|
||||
pub fn diff_numstat(&self, from: &str, to: &str, paths: &[String]) -> IdeResult<Vec<FileLineStats>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::diff_numstat(self, from, to, paths)
|
||||
}
|
||||
/// Tracked files whose working-tree content differs from `rev`.
|
||||
pub fn diff_with_worktree(&self, rev: &str) -> IdeResult<Vec<ChangedFile>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::diff_with_worktree(self, rev)
|
||||
}
|
||||
/// `(repo-relative path, added lines, deleted lines)` of the tracked files whose
|
||||
/// working-tree content differs from `rev`.
|
||||
pub fn numstat_with_worktree(&self, rev: &str) -> IdeResult<Vec<(String, u32, u32)>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::numstat_with_worktree(self, rev)
|
||||
}
|
||||
|
||||
@@ -1633,45 +1632,45 @@ impl Repo {
|
||||
|
||||
/// Patch of the local changes of `paths` against HEAD (untracked files included).
|
||||
pub fn create_patch(&self, paths: &[PathBuf], reverse: bool) -> IdeResult<String> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let rel = self.rel_paths(paths)?;
|
||||
Ok(patch::working_patch(self, &rel, reverse, true)?.0)
|
||||
}
|
||||
/// Patch of the changes made by `commits` (oldest first).
|
||||
pub fn create_commits_patch(&self, commits: &[String], reverse: bool) -> IdeResult<String> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
patch::commits_patch(self, commits, reverse)
|
||||
}
|
||||
pub fn patch_preview(&self, patch: &str) -> IdeResult<Vec<PatchFile>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
patch::preview(self, patch)
|
||||
}
|
||||
/// Applies a patch to the working tree, 3-way merging when it does not apply cleanly.
|
||||
pub fn apply_patch(&self, patch: &str) -> IdeResult<ApplyOutcome> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
patch::apply(self, patch)
|
||||
}
|
||||
/// Saves the changes of `paths` under `shelf_dir` and reverts them.
|
||||
pub fn shelve(&self, shelf_dir: &Path, name: &str, paths: &[PathBuf]) -> IdeResult<ShelvedChangeList> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let rel = self.rel_paths(paths)?;
|
||||
shelf::shelve(self, shelf_dir, name, &rel)
|
||||
}
|
||||
pub fn unshelve(&self, shelf_dir: &Path, id: &str, remove: bool) -> IdeResult<ApplyOutcome> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
shelf::unshelve(self, shelf_dir, id, remove)
|
||||
}
|
||||
|
||||
/// Who is on each side of the conflicts of the operation in progress.
|
||||
pub fn merge_sides(&self) -> IdeResult<MergeSides> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
ops::merge_sides(self)
|
||||
}
|
||||
/// The versions of a conflicted file with the user's work as `ours`, as IDEA's merge
|
||||
/// dialog shows them (sides swapped during a rebase).
|
||||
pub fn merge_versions(&self, path: &Path, encoding: impl Into<TextEncoding>) -> IdeResult<MergeVersions> {
|
||||
let encoding = encoding.into();
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let (base, ours, theirs) = self.conflict_versions(path, encoding)?;
|
||||
let sides = self.merge_sides()?;
|
||||
let (ours, theirs) = if sides.reversed { (theirs, ours) } else { (ours, theirs) };
|
||||
@@ -1688,7 +1687,7 @@ impl Repo {
|
||||
encoding: impl Into<TextEncoding>,
|
||||
) -> IdeResult<(Option<String>, Option<String>, Option<String>)> {
|
||||
let encoding = encoding.into();
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let rel = self.rel_path(path)?;
|
||||
let repo = self.gix()?;
|
||||
let stage = |n: u8| -> IdeResult<Option<String>> {
|
||||
@@ -1698,83 +1697,33 @@ impl Repo {
|
||||
}
|
||||
}
|
||||
|
||||
/// What git started on this thread may do, and which executable it is.
|
||||
#[derive(Clone)]
|
||||
struct Grant {
|
||||
allowed: bool,
|
||||
git: Option<std::sync::Arc<Path>>,
|
||||
}
|
||||
|
||||
// `None`: nobody has decided yet. Git started now is restricted, and the first scope entered
|
||||
// decides. The grant governs the git CLI only: gitoxide follows the repository's own flag.
|
||||
thread_local! { static EXECUTION: std::cell::RefCell<Option<Grant>> = const { std::cell::RefCell::new(None) }; }
|
||||
struct ExecutionScope(Option<Grant>);
|
||||
// decides. The flag governs the git CLI only: gitoxide follows the repository's own flag.
|
||||
thread_local! { static EXECUTION_ALLOWED: std::cell::Cell<Option<bool>> = const { std::cell::Cell::new(None) }; }
|
||||
struct ExecutionScope(Option<bool>);
|
||||
impl ExecutionScope {
|
||||
fn enter(allowed: bool) -> Self {
|
||||
Self::enter_with(allowed, None)
|
||||
}
|
||||
/// The outermost scope decides; a scope inside it can only restrict.
|
||||
fn enter_with(allowed: bool, git: Option<std::sync::Arc<Path>>) -> Self {
|
||||
EXECUTION.with(|current| {
|
||||
let mut current = current.borrow_mut();
|
||||
let grant = match current.as_ref() {
|
||||
Some(outer) => Grant { allowed: outer.allowed && allowed, git: outer.git.clone() },
|
||||
None => Grant { allowed, git },
|
||||
};
|
||||
Self(current.replace(grant))
|
||||
})
|
||||
fn enter(allowed: bool) -> Self {
|
||||
Self(
|
||||
EXECUTION_ALLOWED
|
||||
.with(|current| current.replace(Some(current.get().map_or(allowed, |outer| outer && allowed)))),
|
||||
)
|
||||
}
|
||||
}
|
||||
impl Drop for ExecutionScope {
|
||||
fn drop(&mut self) {
|
||||
EXECUTION.with(|current| *current.borrow_mut() = self.0.take());
|
||||
EXECUTION_ALLOWED.with(|current| current.set(self.0));
|
||||
}
|
||||
}
|
||||
pub(crate) fn execution_allowed() -> bool {
|
||||
EXECUTION.with(|current| current.borrow().as_ref().is_some_and(|grant| grant.allowed))
|
||||
}
|
||||
/// The git executable of the repository whose scope this thread is in, when it may execute.
|
||||
pub(crate) fn scoped_git_executable() -> Option<std::sync::Arc<Path>> {
|
||||
EXECUTION
|
||||
.with(|current| current.borrow().as_ref().filter(|grant| grant.allowed).and_then(|grant| grant.git.clone()))
|
||||
}
|
||||
|
||||
thread_local! { static OPENING_GIT: std::cell::RefCell<Option<std::sync::Arc<Path>>> = const { std::cell::RefCell::new(None) }; }
|
||||
|
||||
/// Runs `f` with `git` (a project's Path to Git executable; `None` for the default) as the git
|
||||
/// executable of every [`Repo`] opened in it on this thread, and of [`init`]: for work on behalf
|
||||
/// of a project that opens its own repositories. It grants no execution.
|
||||
pub fn with_git_executable<T>(git: Option<&Path>, f: impl FnOnce() -> T) -> T {
|
||||
struct Restore(Option<std::sync::Arc<Path>>);
|
||||
impl Drop for Restore {
|
||||
fn drop(&mut self) {
|
||||
OPENING_GIT.with(|opening| *opening.borrow_mut() = self.0.take());
|
||||
}
|
||||
}
|
||||
let git = git.filter(|p| !p.as_os_str().is_empty()).map(std::sync::Arc::from);
|
||||
let _restore = Restore(OPENING_GIT.with(|opening| opening.replace(git)));
|
||||
f()
|
||||
}
|
||||
pub(crate) fn opening_git_executable() -> Option<std::sync::Arc<Path>> {
|
||||
OPENING_GIT.with(|opening| opening.borrow().clone())
|
||||
EXECUTION_ALLOWED.with(|current| current.get().unwrap_or(false))
|
||||
}
|
||||
impl Repo {
|
||||
/// Whether git may run what the repository's config names (hooks, filters, the fsmonitor,
|
||||
/// signature verifiers, a promisor) and use the configured git executable. A repository
|
||||
/// starts without it: only a caller that knows the project is trusted grants it.
|
||||
pub fn set_execution_allowed(&self, allowed: bool) {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
self.execution_allowed.store(allowed, std::sync::atomic::Ordering::Release);
|
||||
}
|
||||
/// The git executable from this repository's project settings (`None` or empty: the default,
|
||||
/// see [`set_default_git_executable`]). A relative path resolves against the worktree root.
|
||||
/// Used only while execution is allowed.
|
||||
pub fn set_git_executable(&self, path: Option<&Path>) {
|
||||
let path = path.filter(|p| !p.as_os_str().is_empty()).map(std::sync::Arc::from);
|
||||
*self.git_executable.write().unwrap_or_else(|p| p.into_inner()) = path;
|
||||
}
|
||||
fn execution_scope(&self) -> ExecutionScope {
|
||||
let git = self.git_executable.read().unwrap_or_else(|p| p.into_inner()).clone();
|
||||
ExecutionScope::enter_with(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire), git)
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,7 @@ pub(crate) fn parse_worktrees(text: &str) -> Vec<Worktree> {
|
||||
impl Repo {
|
||||
/// Merges `branches` into the current branch (Git › Merge…).
|
||||
pub fn merge_with(&self, branches: &[String], options: &MergeOptions) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let args = merge_args(branches, options)?;
|
||||
let args: Vec<&str> = args.iter().map(String::as_str).collect();
|
||||
crate::preserve::around(self, "Local changes saved before merge", || run(self.root(), &args, None).map(|_| ()))
|
||||
@@ -218,7 +218,7 @@ impl Repo {
|
||||
|
||||
/// Rebases the current branch onto `upstream` (or `upstream..HEAD` onto `options.onto`).
|
||||
pub fn rebase_with(&self, upstream: &str, options: &RebaseOptions) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let args = rebase_args(upstream, options)?;
|
||||
let args: Vec<&str> = args.iter().map(String::as_str).collect();
|
||||
crate::preserve::around(self, "Local changes saved before rebase", || run(self.root(), &args, None).map(|_| ()))
|
||||
@@ -234,7 +234,7 @@ impl Repo {
|
||||
cancel: &CancellationToken,
|
||||
on_output: &dyn Fn(String),
|
||||
) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let args = pull_args(remote, branches, rebase, options)?;
|
||||
let args: Vec<&str> = args.iter().map(String::as_str).collect();
|
||||
crate::preserve::around(self, "Local changes saved before update", || {
|
||||
@@ -244,7 +244,7 @@ impl Repo {
|
||||
|
||||
/// Manage Remotes: adds, removes or edits a remote.
|
||||
pub fn edit_remote(&self, edit: &RemoteEdit) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
match edit {
|
||||
RemoteEdit::Add { name, url } => {
|
||||
let (name, url) = (arg(name, "remote name")?, arg(url, "URL")?);
|
||||
@@ -268,7 +268,7 @@ impl Repo {
|
||||
|
||||
/// Working trees of the repository, the main one first.
|
||||
pub fn worktrees(&self) -> IdeResult<Vec<Worktree>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let out = run(self.root(), &["worktree", "list", "--porcelain"], None)?;
|
||||
Ok(parse_worktrees(&out.stdout_str()))
|
||||
}
|
||||
@@ -276,7 +276,7 @@ impl Repo {
|
||||
/// Git › New Worktree…: checks out `commitish` at `path`, on a new branch `new_branch`
|
||||
/// when given (otherwise `commitish` must be a branch not checked out elsewhere).
|
||||
pub fn add_worktree(&self, path: &Path, commitish: &str, new_branch: Option<&str>) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let path = path.to_string_lossy().into_owned();
|
||||
let commitish = arg(commitish, "revision")?;
|
||||
let mut args: Vec<String> = vec!["worktree".into(), "add".into()];
|
||||
@@ -294,7 +294,7 @@ impl Repo {
|
||||
/// Move Worktree…: moves a linked worktree's folder to exactly `to`. An empty folder there
|
||||
/// is replaced (Git would move the worktree inside it); any other existing `to` is refused.
|
||||
pub fn move_worktree(&self, path: &Path, to: &Path) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
if std::fs::symlink_metadata(to).is_ok() {
|
||||
let empty_dir = to.is_dir() && std::fs::read_dir(to).is_ok_and(|mut d| d.next().is_none());
|
||||
if !empty_dir {
|
||||
@@ -307,7 +307,7 @@ impl Repo {
|
||||
}
|
||||
|
||||
pub fn remove_worktree(&self, path: &Path, force: bool) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let path = path.to_string_lossy().into_owned();
|
||||
let mut args = vec!["worktree", "remove"];
|
||||
if force {
|
||||
|
||||
@@ -43,14 +43,14 @@ pub(crate) fn parse_remotes(text: &str) -> Vec<Remote> {
|
||||
impl Repo {
|
||||
/// Configured remotes with their fetch URLs.
|
||||
pub fn remotes(&self) -> IdeResult<Vec<Remote>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let out = cli::run(self.root(), &["remote", "-v"], None)?;
|
||||
Ok(parse_remotes(&out.stdout_str()))
|
||||
}
|
||||
|
||||
/// Whether `rev` names a commit present in the object database.
|
||||
pub fn has_commit(&self, rev: &str) -> bool {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
check_rev(rev).is_ok()
|
||||
&& cli::run_raw(self.root(), &["cat-file", "-e", &format!("{rev}^{{commit}}")], None)
|
||||
.is_ok_and(|o| o.code == Some(0))
|
||||
@@ -65,7 +65,7 @@ impl Repo {
|
||||
cancel: &CancellationToken,
|
||||
on_output: &dyn Fn(String),
|
||||
) -> IdeResult<()> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
check_rev(remote)?;
|
||||
for r in refspecs {
|
||||
check_rev(r)?;
|
||||
@@ -77,7 +77,7 @@ impl Repo {
|
||||
|
||||
/// The best common ancestor of two revisions, if any.
|
||||
pub fn merge_base(&self, a: &str, b: &str) -> IdeResult<Option<String>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
check_rev(a)?;
|
||||
check_rev(b)?;
|
||||
let out = cli::run_raw(self.root(), &["merge-base", a, b], None)?;
|
||||
@@ -86,7 +86,7 @@ impl Repo {
|
||||
|
||||
/// Files changed between two revisions (renames detected).
|
||||
pub fn diff_files(&self, from: &str, to: &str) -> IdeResult<Vec<ChangedFile>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
check_rev(from)?;
|
||||
check_rev(to)?;
|
||||
let out = cli::run(
|
||||
|
||||
@@ -72,7 +72,6 @@ pub(crate) fn discover(path: &Path) -> IdeResult<Option<Repo>> {
|
||||
let cache = Cache { stamp: stamp(&files), files, repo: ts, pack_stamp: pack_stamp(&pack_dir), pack_dir };
|
||||
Ok(Some(Repo {
|
||||
execution_allowed: std::sync::atomic::AtomicBool::new(false),
|
||||
git_executable: std::sync::RwLock::new(crate::opening_git_executable()),
|
||||
root,
|
||||
git_dir,
|
||||
inner: std::sync::Mutex::new(cache),
|
||||
@@ -103,7 +102,7 @@ impl Repo {
|
||||
/// A thread-local gitoxide handle; reopened when configuration or packed refs change.
|
||||
/// gitoxide's packed-ref snapshot only reloads for a newer mtime, which a replacement may preserve.
|
||||
pub(crate) fn gix(&self) -> IdeResult<gix::Repository> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
if !self.execution_allowed.load(std::sync::atomic::Ordering::Acquire) {
|
||||
return gix::open_opts(&self.git_dir, gix::open::Options::default().filter_config_section(|_| false))
|
||||
.map_err(gx);
|
||||
@@ -129,7 +128,7 @@ impl Repo {
|
||||
/// Repository-relative path with `/` separators. Accepts absolute paths inside the
|
||||
/// worktree or paths already relative to it.
|
||||
pub(crate) fn rel_path(&self, path: &Path) -> IdeResult<String> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
Ok(self.index_spelling(self.given_rel_path(path)?))
|
||||
}
|
||||
|
||||
@@ -218,7 +217,7 @@ impl Repo {
|
||||
|
||||
/// Absolute path for a repository-relative path.
|
||||
pub(crate) fn abs_path(&self, rel: &str) -> PathBuf {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let mut p = self.root.clone();
|
||||
for part in rel.split('/').filter(|s| !s.is_empty()) {
|
||||
p.push(part);
|
||||
|
||||
@@ -200,7 +200,7 @@ pub(crate) fn unshelve(r: &Repo, shelf: &Path, id: &str, remove: bool) -> IdeRes
|
||||
}
|
||||
|
||||
pub fn unshelve_path(r: &Repo, shelf: &Path, id: &str, remove: bool, path: Option<&str>) -> IdeResult<ApplyOutcome> {
|
||||
let _scope = r.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(r.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let patch = selected_patch(shelf, id, path)?;
|
||||
let outcome = crate::patch::apply(r, &patch)?;
|
||||
if remove && outcome.conflicts.is_empty() {
|
||||
@@ -292,7 +292,7 @@ pub fn delete_path(shelf: &Path, id: &str, path: Option<&str>) -> IdeResult<()>
|
||||
|
||||
/// Reconstruct each side in a throwaway index; neither HEAD nor the working files are used.
|
||||
pub fn diff_files(r: &Repo, shelf: &Path, id: &str) -> IdeResult<Vec<ShelfDiffFile>> {
|
||||
let _scope = r.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(r.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let patch = patch_of(shelf, id)?;
|
||||
let mut out = Vec::new();
|
||||
for (section, file) in sections(&patch) {
|
||||
|
||||
@@ -17,7 +17,7 @@ const UNCOMMITTED_AUTHOR: &str = "Not Committed Yet";
|
||||
|
||||
impl Repo {
|
||||
pub(crate) fn rel_paths(&self, paths: &[PathBuf]) -> IdeResult<Vec<String>> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
paths
|
||||
.iter()
|
||||
.map(|p| {
|
||||
@@ -28,7 +28,7 @@ impl Repo {
|
||||
}
|
||||
|
||||
pub(crate) fn has_head(&self) -> IdeResult<bool> {
|
||||
let _scope = self.execution_scope();
|
||||
let _scope = crate::ExecutionScope::enter(self.execution_allowed.load(std::sync::atomic::Ordering::Acquire));
|
||||
let repo = self.gix()?;
|
||||
Ok(!repo.head().map_err(gx)?.is_unborn())
|
||||
}
|
||||
|
||||
@@ -355,11 +355,6 @@ impl SettingsStore {
|
||||
self.effective.read().clone()
|
||||
}
|
||||
|
||||
/// Reads part of the effective settings without copying all of them.
|
||||
pub fn read_effective<T>(&self, read: impl FnOnce(&Settings) -> T) -> T {
|
||||
read(&self.effective.read())
|
||||
}
|
||||
|
||||
/// Settings defined in `scope`'s file alone (without merging the other layer).
|
||||
pub fn layer(&self, scope: SettingsScope) -> Settings {
|
||||
let mut merged = defaults_json();
|
||||
|
||||
@@ -67,7 +67,7 @@ mise run dev
|
||||
|
||||
`setup` runs `pnpm install` in this worktree. `dev` and `dev:app` use the same worktree-aware launchers as the direct commands. No shell activation is needed for `mise run`.
|
||||
|
||||
Run `mise tasks` to list all tasks. `mise run build` builds the frontend (not a desktop installer); `mise run dogfood:build` and `mise run dogfood:install` build and locally install a grey-icon dogfood desktop app that shares settings and data with the release app. Only one of the two apps runs at a time, since they share one instance; settings written by the newer dogfood build can make an older release ignore the settings file. The dogfood app never updates itself: run `dogfood:install` again to pick up new changes. `mise run dogfood:remote <remote_name>` builds and stages `openidea-server` on an SSH host configured in **Tools › SSH Configurations** (`--clean` removes the override). `mise run test` runs Vitest and `cargo test --workspace`; `mise run check` runs the format, lint, type and unused-code checks, then both test suites. Neither requires nextest or the plugin WASM target.
|
||||
Run `mise tasks` to list all tasks. `mise run build` builds the frontend (not a desktop installer); `mise run dogfood:build` and `mise run dogfood:install` build and locally install a grey-icon dogfood desktop app that shares settings and data with the release app. Only one of the two apps runs at a time, since they share one instance; settings written by the newer dogfood build can make an older release ignore the settings file. The dogfood app never updates itself: run `dogfood:install` again to pick up new changes. `mise run test` runs Vitest and `cargo test --workspace`; `mise run check` runs the format, lint, type and unused-code checks, then both test suites. Neither requires nextest or the plugin WASM target.
|
||||
|
||||
## Worktrees
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ All folding commands are also in **Code › Folding**. Fold regions come from th
|
||||
| **Auto-Indent Lines** | `⌃⌥I` | `Ctrl+Alt+I` |
|
||||
| **Optimize Imports** | `⌃⌥O` | `Ctrl+Alt+O` |
|
||||
|
||||
**Reformat Code** formats the selection, or the whole file when nothing is selected, as one undo step. The formatting comes from the file's language server or from the formatter the language is configured with (for example Ruff for Python, Prettier, oxfmt or Biome for web languages; find their commands as **Reformat with …** in Find Action). **Reformat File…** also lets you choose the scope and optimize imports.
|
||||
**Reformat Code** formats the selection, or the whole file when nothing is selected, as one undo step. The formatting comes from the file's language server or from the formatter the language is configured with (for example Ruff for Python, Prettier or oxfmt for web languages; find their commands as **Reformat with …** in Find Action). **Reformat File…** also lets you choose the scope and optimize imports.
|
||||
|
||||
Indentation and other style options are under **Settings › Editor › Code Style**, with a page per language. `.editorconfig` files in the project are read too.
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ Detected test configurations show results in the tree automatically. For your ow
|
||||
| **Rerun** (in the Run tool window) | `⌘R` | `Ctrl+F5` |
|
||||
| **Rerun Failed Tests** | — | — |
|
||||
|
||||
**Rerun Failed Tests** (in the Run tool window toolbar and Find Action) runs only the tests that failed in the last run, using each tool's filter syntax. It works for Cargo, Jest / Vitest, Playwright, `node --test`, Mocha, pytest, Django, PHPUnit, Go, Maven / Gradle and .NET runs, and for plugin test frameworks.
|
||||
**Rerun Failed Tests** (in the Run tool window toolbar and Find Action) runs only the tests that failed in the last run, using each tool's filter syntax. It works for Cargo, Jest / Vitest, Playwright, `node --test`, pytest, Django, PHPUnit, Go, Maven / Gradle and .NET runs, and for plugin test frameworks.
|
||||
|
||||
## Navigate between code and tests
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ For a recognized file, support comes in layers:
|
||||
A language can list more than one server:
|
||||
|
||||
- **Alternatives** (shown as `a → b` in the table below): only the first one that is installed runs. Python, for example, uses basedpyright, and falls back to pyright, ty or pyrefly only when basedpyright is missing. In **Settings › Languages & Frameworks › Language Servers** you can pick one of them or set the choice to **Automatic** (the first one available).
|
||||
- **Additions** (shown as `+ b`): run next to the main server, usually only in projects that use them. Ruff joins basedpyright in projects with a Ruff configuration; oxlint joins vtsls in projects with an oxlint configuration; Stylelint joins the CSS, SCSS and Less server in projects with a Stylelint configuration (`.stylelintrc*`, `stylelint.config.*` or `stylelint` in `package.json`), running the project's own `stylelint` (**Fix Stylelint Problems** in the editor's context menu applies its fixes); Biome joins the JavaScript, TypeScript, JSON, CSS and GraphQL servers in projects with a Biome configuration or installation; the Angular, Laravel and Tailwind CSS servers join in Angular, Laravel and Tailwind CSS projects.
|
||||
- **Additions** (shown as `+ b`): run next to the main server, usually only in projects that use them. Ruff joins basedpyright in projects with a Ruff configuration; oxlint joins vtsls in projects with an oxlint configuration; the Angular and Laravel servers join in Angular and Laravel projects.
|
||||
|
||||
## Installing language servers and debuggers
|
||||
|
||||
@@ -91,92 +91,92 @@ Selecting a language server on the Language Servers page shows its settings, whi
|
||||
|
||||
The table lists every built-in language definition. Server and debugger names in **bold** can be installed from the IDE; the others you install yourself (the install hint in the IDE says how). "Highlighting" and "Tree-sitter" mark instant highlighting and the bundled grammar for outline and folding.
|
||||
|
||||
| Language | ID | Files | Highlighting | Tree-sitter | Language servers | Debugger |
|
||||
| ------------------- | ------------------ | ----------------------------------------------------------- | ------------ | ----------- | ------------------------------------------------------------------------------------------------- | ------------------------ |
|
||||
| .env | `dotenv` | `.env` | Yes | — | — | — |
|
||||
| Arduino | `arduino` | `.ino` | Yes | Yes | arduino-language-server | — |
|
||||
| AsciiDoc | `asciidoc` | `.adoc`, `.asciidoc` | Yes | — | — | — |
|
||||
| Astro | `astro` | `.astro` | Yes | — | **astro-ls** + **oxlint** | — |
|
||||
| Batch | `bat` | `.bat`, `.cmd` | Yes | — | — | — |
|
||||
| C | `c` | `.c`, `.h` | Yes | Yes | **clangd** | lldb-dap |
|
||||
| C# | `csharp` | `.cs`, `.csx` | Yes | Yes | **csharp-ls** | **netcoredbg** |
|
||||
| C++ | `cpp` | `.cpp`, `.cc`, `.cxx`, `.c++`, `.hpp`, … | Yes | Yes | **clangd** | lldb-dap |
|
||||
| Clojure | `clojure` | `.clj`, `.cljs`, `.cljc`, `.cljd`, `.edn`, … | Yes | — | **clojure-lsp** | — |
|
||||
| CMake | `cmake` | `.cmake` | Yes | Yes | **neocmakelsp** → cmake-language-server | — |
|
||||
| CSS | `css` | `.css`, `.pcss`, `.postcss` | Yes | Yes | **vscode-css-language-server** + **biome** + **stylelint** | — |
|
||||
| D | `d` | `.d`, `.di` | Yes | — | serve-d | — |
|
||||
| Dart | `dart` | `.dart` | Yes | Yes | dart | dart |
|
||||
| Diff | `diff` | `.diff`, `.patch`, `.rej` | Yes | — | — | — |
|
||||
| Django Template | `django-html` | `.djhtml`, `templates/*.html`, `*.txt` | Yes | Yes | **vscode-html-language-server**, **djlsp** | — |
|
||||
| Dockerfile | `dockerfile` | `.dockerfile`, `.containerfile` | Yes | — | **dockerfile-language-server** | — |
|
||||
| Elixir | `elixir` | `.ex`, `.exs` | Yes | Yes | **elixir-ls** | **elixir-ls-debugger** |
|
||||
| ERB | `erb` | `.erb`, `.html.erb`, `.rhtml`, `.js.erb`, `.text.erb`, … | Yes | — | — | — |
|
||||
| Erlang | `erlang` | `.erl`, `.hrl`, `.escript`, `.app.src` | Yes | — | elp | — |
|
||||
| F# | `fsharp` | `.fs`, `.fsi`, `.fsx` | Yes | — | **fsautocomplete** | **netcoredbg** |
|
||||
| GDScript | `gdscript` | `.gd` | Yes | Yes | godot | godot |
|
||||
| Git Attributes | `gitattributes` | `.gitattributes` | — | — | — | — |
|
||||
| Go | `go` | `.go` | Yes | Yes | **gopls** | **delve** |
|
||||
| Go Module | `go.mod` | `go.mod` | Yes | — | **gopls** | — |
|
||||
| Go Workspace | `go.work` | `go.work` | Yes | — | **gopls** | — |
|
||||
| Godot Resource | `godot-resource` | `.tscn`, `.tres`, `.godot`, `.import` | Yes | — | — | — |
|
||||
| Godot Shader | `gdshader` | `.gdshader`, `.gdshaderinc` | Yes | — | — | — |
|
||||
| GraphQL | `graphql` | `.graphql`, `.graphqls`, `.gql` | Yes | Yes | **graphql-lsp** + **biome** | — |
|
||||
| Groovy | `groovy` | `.groovy`, `.gradle`, `.gvy`, `.gy`, `.gsh` | Yes | — | groovy-language-server | — |
|
||||
| Haskell | `haskell` | `.hs`, `.hs-boot`, `.hsig` | Yes | Yes | haskell-language-server | — |
|
||||
| HCL | `hcl` | `.hcl`, `.nomad`, `.pkr.hcl` | Yes | Yes | — | — |
|
||||
| HTML | `html` | `.html`, `.htm`, `.xhtml`, `.shtml`, `.html.tmpl` | Yes | Yes | **vscode-html-language-server** + **angular-language-server** | — |
|
||||
| HTTP Request | `http` | `.http`, `.rest` | Yes | — | — | — |
|
||||
| Ignore File | `ignore` | `.gitignore`, `.dockerignore` | — | — | — | — |
|
||||
| INI | `ini` | `.ini`, `.cfg`, `.conf`, `.cnf`, `.inf`, … | Yes | — | — | — |
|
||||
| Java | `java` | `.java` | Yes | Yes | **jdtls** → **java-analyzer** → **kmp-lsp** | **java-debug** |
|
||||
| JavaScript | `javascript` | `.js`, `.mjs`, `.cjs` | Yes | Yes | **vtsls** → **typescript-language-server** + **oxlint** + **biome** | **js-debug** |
|
||||
| JavaScript JSX | `javascriptreact` | `.jsx` | Yes | Yes | **vtsls** → **typescript-language-server** + **oxlint** + **biome** | **js-debug** |
|
||||
| JSON | `json` | `.json`, `.geojson`, `.topojson`, `.webmanifest`, `.har`, … | Yes | Yes | **vscode-json-language-server** + **biome** | — |
|
||||
| JSON with Comments | `jsonc` | `.jsonc`, `.code-workspace`, `.code-snippets` | Yes | Yes | **vscode-json-language-server** + **biome** | — |
|
||||
| JSP | `jsp` | `.jsp`, `.jspx`, `.jspf`, `.jsph`, `.tag`, … | Yes | — | — | — |
|
||||
| Julia | `julia` | `.jl` | Yes | — | julia-languageserver | — |
|
||||
| Kotlin | `kotlin` | `.kt`, `.kts` | Yes | Yes | **kotlin-lsp** → **kotlin-language-server** → **kmp-lsp** | **kotlin-debug-adapter** |
|
||||
| LaTeX | `latex` | `.tex`, `.ltx`, `.sty`, `.cls`, `.dtx`, … | Yes | — | **texlab** | — |
|
||||
| Less | `less` | `.less` | Yes | — | **vscode-css-language-server** + **stylelint** | — |
|
||||
| Log | `log` | `.log` | Yes | — | — | — |
|
||||
| Lua | `lua` | `.lua`, `.luau`, `.rockspec` | Yes | Yes | **lua-language-server** | — |
|
||||
| Makefile | `makefile` | `.mk`, `.mak`, `.make` | Yes | Yes | — | — |
|
||||
| Markdown | `markdown` | `.md`, `.markdown`, `.mdown`, `.mkd`, `.mkdn`, … | Yes | Yes | **marksman** | — |
|
||||
| Nix | `nix` | `.nix` | Yes | Yes | nil → nixd | — |
|
||||
| Objective-C | `objective-c` | `.m` | Yes | — | **clangd** | lldb-dap |
|
||||
| Objective-C++ | `objective-cpp` | `.mm` | Yes | — | **clangd** | lldb-dap |
|
||||
| OCaml | `ocaml` | `.ml`, `.mll`, `.mly` | Yes | Yes | ocamllsp | ocamlearlybird |
|
||||
| OCaml Interface | `ocaml.interface` | `.mli` | Yes | Yes | ocamllsp | — |
|
||||
| Perl | `perl` | `.pl`, `.pm`, `.pod`, `.psgi`, `.cgi` | Yes | — | **perlnavigator** | — |
|
||||
| PHP | `php` | `.php`, `.phtml`, `.php3`, `.php4`, `.php5`, … | Yes | Yes | **intelephense** → phpactor → **phoxite** + **laravel-lsp** | **php-debug** |
|
||||
| Plain Text | `plaintext` | `.txt`, `.text` | — | — | — | — |
|
||||
| PowerShell | `powershell` | `.ps1`, `.psm1`, `.psd1`, `.pssc`, `.psrc` | Yes | — | powershell-editor-services | — |
|
||||
| Prisma | `prisma` | `.prisma` | Yes | Yes | **prisma-language-server** | — |
|
||||
| Properties | `properties` | `.properties`, `.prefs` | Yes | — | — | — |
|
||||
| Protocol Buffers | `proto` | `.proto` | Yes | Yes | **buf** | — |
|
||||
| Python | `python` | `.py`, `.pyi`, `.pyw` | Yes | Yes | **basedpyright** → **pyright** → **ty** → **pyrefly** + **ruff** | **debugpy** |
|
||||
| R | `r` | `.r`, `.rprofile` | Yes | — | r-languageserver | — |
|
||||
| reStructuredText | `restructuredtext` | `.rst` | Yes | — | — | — |
|
||||
| Ruby | `ruby` | `.rb`, `.rake`, `.gemspec`, `.ru`, `.rbi`, … | Yes | Yes | **ruby-lsp** → **solargraph** | rdbg |
|
||||
| Rust | `rust` | `.rs` | Yes | Yes | **rust-analyzer** | **codelldb** |
|
||||
| Sass | `sass` | `.sass` | Yes | — | — | — |
|
||||
| Scala | `scala` | `.scala`, `.sc`, `.sbt`, `.mill` | Yes | Yes | metals | — |
|
||||
| SCSS | `scss` | `.scss` | Yes | — | **vscode-css-language-server** + **stylelint** | — |
|
||||
| Shell Script | `shellscript` | `.sh`, `.bash`, `.zsh`, `.ksh`, `.ash`, … | Yes | Yes | **bash-language-server** | **bash-debug** |
|
||||
| Slint | `slint` | `.slint` | Yes | — | **slint-lsp** | — |
|
||||
| SQL | `sql` | `.sql`, `.ddl`, `.dml`, `.psql`, `.pgsql`, … | Yes | — | **sqls** | — |
|
||||
| Svelte | `svelte` | `.svelte` | Yes | — | **svelte-language-server** + **oxlint** | — |
|
||||
| Swift | `swift` | `.swift`, `.swiftinterface` | Yes | Yes | sourcekit-lsp | lldb-dap |
|
||||
| Terraform | `terraform` | `.tf`, `.tofu`, `.tftest.hcl` | Yes | Yes | **terraform-ls** | — |
|
||||
| Terraform Variables | `terraform-vars` | `.tfvars` | Yes | Yes | **terraform-ls** | — |
|
||||
| TOML | `toml` | `.toml` | Yes | Yes | **taplo** | — |
|
||||
| TypeScript | `typescript` | `.ts`, `.mts`, `.cts` | Yes | Yes | **vtsls** → **typescript-language-server** + **angular-language-server** + **oxlint** + **biome** | **js-debug** |
|
||||
| TypeScript JSX | `typescriptreact` | `.tsx` | Yes | Yes | **vtsls** → **typescript-language-server** + **oxlint** + **biome** | **js-debug** |
|
||||
| Typst | `typst` | `.typ` | — | — | **tinymist** | — |
|
||||
| Vue | `vue` | `.vue` | Yes | — | **vue-language-server**, **vtsls** + **oxlint** | — |
|
||||
| XML | `xml` | `.xml`, `.xsd`, `.xsl`, `.xslt`, `.svg`, … | Yes | Yes | **lemminx** | — |
|
||||
| YAML | `yaml` | `.yaml`, `.yml` | Yes | Yes | **yaml-language-server** | — |
|
||||
| Zig | `zig` | `.zig`, `.zon` | Yes | Yes | **zls** | **codelldb** |
|
||||
| Language | ID | Files | Highlighting | Tree-sitter | Language servers | Debugger |
|
||||
| ------------------- | ------------------ | ----------------------------------------------------------- | ------------ | ----------- | ------------------------------------------------------------------------------------- | ------------------------ |
|
||||
| .env | `dotenv` | `.env` | Yes | — | — | — |
|
||||
| Arduino | `arduino` | `.ino` | Yes | Yes | arduino-language-server | — |
|
||||
| AsciiDoc | `asciidoc` | `.adoc`, `.asciidoc` | Yes | — | — | — |
|
||||
| Astro | `astro` | `.astro` | Yes | — | **astro-ls** + **oxlint** | — |
|
||||
| Batch | `bat` | `.bat`, `.cmd` | Yes | — | — | — |
|
||||
| C | `c` | `.c`, `.h` | Yes | Yes | **clangd** | lldb-dap |
|
||||
| C# | `csharp` | `.cs`, `.csx` | Yes | Yes | **csharp-ls** | **netcoredbg** |
|
||||
| C++ | `cpp` | `.cpp`, `.cc`, `.cxx`, `.c++`, `.hpp`, … | Yes | Yes | **clangd** | lldb-dap |
|
||||
| Clojure | `clojure` | `.clj`, `.cljs`, `.cljc`, `.cljd`, `.edn`, … | Yes | — | **clojure-lsp** | — |
|
||||
| CMake | `cmake` | `.cmake` | Yes | Yes | **neocmakelsp** → cmake-language-server | — |
|
||||
| CSS | `css` | `.css`, `.pcss`, `.postcss` | Yes | Yes | **vscode-css-language-server** | — |
|
||||
| D | `d` | `.d`, `.di` | Yes | — | serve-d | — |
|
||||
| Dart | `dart` | `.dart` | Yes | Yes | dart | dart |
|
||||
| Diff | `diff` | `.diff`, `.patch`, `.rej` | Yes | — | — | — |
|
||||
| Django Template | `django-html` | `.djhtml`, `templates/*.html`, `*.txt` | Yes | Yes | **vscode-html-language-server**, **djlsp** | — |
|
||||
| Dockerfile | `dockerfile` | `.dockerfile`, `.containerfile` | Yes | — | **dockerfile-language-server** | — |
|
||||
| Elixir | `elixir` | `.ex`, `.exs` | Yes | Yes | **elixir-ls** | **elixir-ls-debugger** |
|
||||
| ERB | `erb` | `.erb`, `.html.erb`, `.rhtml`, `.js.erb`, `.text.erb`, … | Yes | — | — | — |
|
||||
| Erlang | `erlang` | `.erl`, `.hrl`, `.escript`, `.app.src` | Yes | — | elp | — |
|
||||
| F# | `fsharp` | `.fs`, `.fsi`, `.fsx` | Yes | — | **fsautocomplete** | **netcoredbg** |
|
||||
| GDScript | `gdscript` | `.gd` | Yes | Yes | godot | godot |
|
||||
| Git Attributes | `gitattributes` | `.gitattributes` | — | — | — | — |
|
||||
| Go | `go` | `.go` | Yes | Yes | **gopls** | **delve** |
|
||||
| Go Module | `go.mod` | `go.mod` | Yes | — | **gopls** | — |
|
||||
| Go Workspace | `go.work` | `go.work` | Yes | — | **gopls** | — |
|
||||
| Godot Resource | `godot-resource` | `.tscn`, `.tres`, `.godot`, `.import` | Yes | — | — | — |
|
||||
| Godot Shader | `gdshader` | `.gdshader`, `.gdshaderinc` | Yes | — | — | — |
|
||||
| GraphQL | `graphql` | `.graphql`, `.graphqls`, `.gql` | Yes | Yes | **graphql-lsp** | — |
|
||||
| Groovy | `groovy` | `.groovy`, `.gradle`, `.gvy`, `.gy`, `.gsh` | Yes | — | groovy-language-server | — |
|
||||
| Haskell | `haskell` | `.hs`, `.hs-boot`, `.hsig` | Yes | Yes | haskell-language-server | — |
|
||||
| HCL | `hcl` | `.hcl`, `.nomad`, `.pkr.hcl` | Yes | Yes | — | — |
|
||||
| HTML | `html` | `.html`, `.htm`, `.xhtml`, `.shtml`, `.html.tmpl` | Yes | Yes | **vscode-html-language-server** + **angular-language-server** | — |
|
||||
| HTTP Request | `http` | `.http`, `.rest` | Yes | — | — | — |
|
||||
| Ignore File | `ignore` | `.gitignore`, `.dockerignore` | — | — | — | — |
|
||||
| INI | `ini` | `.ini`, `.cfg`, `.conf`, `.cnf`, `.inf`, … | Yes | — | — | — |
|
||||
| Java | `java` | `.java` | Yes | Yes | **jdtls** → **java-analyzer** → **kmp-lsp** | **java-debug** |
|
||||
| JavaScript | `javascript` | `.js`, `.mjs`, `.cjs` | Yes | Yes | **vtsls** → **typescript-language-server** + **oxlint** | **js-debug** |
|
||||
| JavaScript JSX | `javascriptreact` | `.jsx` | Yes | Yes | **vtsls** → **typescript-language-server** + **oxlint** | **js-debug** |
|
||||
| JSON | `json` | `.json`, `.geojson`, `.topojson`, `.webmanifest`, `.har`, … | Yes | Yes | **vscode-json-language-server** | — |
|
||||
| JSON with Comments | `jsonc` | `.jsonc`, `.code-workspace`, `.code-snippets` | Yes | Yes | **vscode-json-language-server** | — |
|
||||
| JSP | `jsp` | `.jsp`, `.jspx`, `.jspf`, `.jsph`, `.tag`, … | Yes | — | — | — |
|
||||
| Julia | `julia` | `.jl` | Yes | — | julia-languageserver | — |
|
||||
| Kotlin | `kotlin` | `.kt`, `.kts` | Yes | Yes | **kotlin-lsp** → **kotlin-language-server** → **kmp-lsp** | **kotlin-debug-adapter** |
|
||||
| LaTeX | `latex` | `.tex`, `.ltx`, `.sty`, `.cls`, `.dtx`, … | Yes | — | **texlab** | — |
|
||||
| Less | `less` | `.less` | Yes | — | **vscode-css-language-server** | — |
|
||||
| Log | `log` | `.log` | Yes | — | — | — |
|
||||
| Lua | `lua` | `.lua`, `.luau`, `.rockspec` | Yes | Yes | **lua-language-server** | — |
|
||||
| Makefile | `makefile` | `.mk`, `.mak`, `.make` | Yes | Yes | — | — |
|
||||
| Markdown | `markdown` | `.md`, `.markdown`, `.mdown`, `.mkd`, `.mkdn`, … | Yes | Yes | **marksman** | — |
|
||||
| Nix | `nix` | `.nix` | Yes | Yes | nil → nixd | — |
|
||||
| Objective-C | `objective-c` | `.m` | Yes | — | **clangd** | lldb-dap |
|
||||
| Objective-C++ | `objective-cpp` | `.mm` | Yes | — | **clangd** | lldb-dap |
|
||||
| OCaml | `ocaml` | `.ml`, `.mll`, `.mly` | Yes | Yes | ocamllsp | ocamlearlybird |
|
||||
| OCaml Interface | `ocaml.interface` | `.mli` | Yes | Yes | ocamllsp | — |
|
||||
| Perl | `perl` | `.pl`, `.pm`, `.pod`, `.psgi`, `.cgi` | Yes | — | **perlnavigator** | — |
|
||||
| PHP | `php` | `.php`, `.phtml`, `.php3`, `.php4`, `.php5`, … | Yes | Yes | **intelephense** → phpactor → **phoxite** + **laravel-lsp** | **php-debug** |
|
||||
| Plain Text | `plaintext` | `.txt`, `.text` | — | — | — | — |
|
||||
| PowerShell | `powershell` | `.ps1`, `.psm1`, `.psd1`, `.pssc`, `.psrc` | Yes | — | powershell-editor-services | — |
|
||||
| Prisma | `prisma` | `.prisma` | Yes | Yes | **prisma-language-server** | — |
|
||||
| Properties | `properties` | `.properties`, `.prefs` | Yes | — | — | — |
|
||||
| Protocol Buffers | `proto` | `.proto` | Yes | Yes | **buf** | — |
|
||||
| Python | `python` | `.py`, `.pyi`, `.pyw` | Yes | Yes | **basedpyright** → **pyright** → **ty** → **pyrefly** + **ruff** | **debugpy** |
|
||||
| R | `r` | `.r`, `.rprofile` | Yes | — | r-languageserver | — |
|
||||
| reStructuredText | `restructuredtext` | `.rst` | Yes | — | — | — |
|
||||
| Ruby | `ruby` | `.rb`, `.rake`, `.gemspec`, `.ru`, `.rbi`, … | Yes | Yes | **ruby-lsp** → **solargraph** | rdbg |
|
||||
| Rust | `rust` | `.rs` | Yes | Yes | **rust-analyzer** | **codelldb** |
|
||||
| Sass | `sass` | `.sass` | Yes | — | — | — |
|
||||
| Scala | `scala` | `.scala`, `.sc`, `.sbt`, `.mill` | Yes | Yes | metals | — |
|
||||
| SCSS | `scss` | `.scss` | Yes | — | **vscode-css-language-server** | — |
|
||||
| Shell Script | `shellscript` | `.sh`, `.bash`, `.zsh`, `.ksh`, `.ash`, … | Yes | Yes | **bash-language-server** | **bash-debug** |
|
||||
| Slint | `slint` | `.slint` | Yes | — | **slint-lsp** | — |
|
||||
| SQL | `sql` | `.sql`, `.ddl`, `.dml`, `.psql`, `.pgsql`, … | Yes | — | **sqls** | — |
|
||||
| Svelte | `svelte` | `.svelte` | Yes | — | **svelte-language-server** + **oxlint** | — |
|
||||
| Swift | `swift` | `.swift`, `.swiftinterface` | Yes | Yes | sourcekit-lsp | lldb-dap |
|
||||
| Terraform | `terraform` | `.tf`, `.tofu`, `.tftest.hcl` | Yes | Yes | **terraform-ls** | — |
|
||||
| Terraform Variables | `terraform-vars` | `.tfvars` | Yes | Yes | **terraform-ls** | — |
|
||||
| TOML | `toml` | `.toml` | Yes | Yes | **taplo** | — |
|
||||
| TypeScript | `typescript` | `.ts`, `.mts`, `.cts` | Yes | Yes | **vtsls** → **typescript-language-server** + **angular-language-server** + **oxlint** | **js-debug** |
|
||||
| TypeScript JSX | `typescriptreact` | `.tsx` | Yes | Yes | **vtsls** → **typescript-language-server** + **oxlint** | **js-debug** |
|
||||
| Typst | `typst` | `.typ` | — | — | **tinymist** | — |
|
||||
| Vue | `vue` | `.vue` | Yes | — | **vue-language-server**, **vtsls** + **oxlint** | — |
|
||||
| XML | `xml` | `.xml`, `.xsd`, `.xsl`, `.xslt`, `.svg`, … | Yes | Yes | **lemminx** | — |
|
||||
| YAML | `yaml` | `.yaml`, `.yml` | Yes | Yes | **yaml-language-server** | — |
|
||||
| Zig | `zig` | `.zig`, `.zon` | Yes | Yes | **zls** | **codelldb** |
|
||||
|
||||
Notes:
|
||||
|
||||
|
||||
@@ -7,18 +7,16 @@ OpenIDEA edits JavaScript (`.js`, `.mjs`, `.cjs`, `.jsx`) and TypeScript (`.ts`,
|
||||
|
||||
## Language servers
|
||||
|
||||
| Files | Server | Notes |
|
||||
| ------------------------------- | -------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| JS, JSX, TS, TSX | `vtsls` | Default TypeScript server. |
|
||||
| JS, JSX, TS, TSX | `typescript-language-server` | Fallback: used only while `vtsls` is not installed. |
|
||||
| `.vue` | `vue-language-server` + `vtsls` | Vue's hybrid mode: TypeScript inside `.vue` files comes from `vtsls` with `@vue/typescript-plugin`. |
|
||||
| `.svelte` | `svelte-language-server` | |
|
||||
| `.astro` | `astro-ls` | Needs Node.js and a TypeScript library. |
|
||||
| TS and HTML in Angular projects | `angular-language-server` (`ngserver`) | Only below `angular.json` or `node_modules/@angular/core`. |
|
||||
| All of the above | `oxlint` | Only below an `.oxlintrc.json`, `.oxlintrc.jsonc`, `oxlint.config.ts` or `oxlint.config.mts`. |
|
||||
| All of the above | `vscode-eslint-language-server` (ESLint) | Only below an ESLint configuration (`eslint.config.*`, `.eslintrc*` or `eslintConfig` in `package.json`); runs the project's own `eslint`. |
|
||||
| JS, JSX, TS, TSX, JSON, CSS | `biome lsp-proxy` (Biome) | Only below a `biome.json` / `biome.jsonc` or an installed `@biomejs/biome`; runs the project's own `biome`. |
|
||||
| All of the above, HTML and CSS | `tailwindcss-language-server` (Tailwind CSS) | Only below a `tailwind.config.*` or a `package.json` that depends on `tailwindcss`: class completion, hover with the generated CSS, and class diagnostics. |
|
||||
| Files | Server | Notes |
|
||||
| ------------------------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| JS, JSX, TS, TSX | `vtsls` | Default TypeScript server. |
|
||||
| JS, JSX, TS, TSX | `typescript-language-server` | Fallback: used only while `vtsls` is not installed. |
|
||||
| `.vue` | `vue-language-server` + `vtsls` | Vue's hybrid mode: TypeScript inside `.vue` files comes from `vtsls` with `@vue/typescript-plugin`. |
|
||||
| `.svelte` | `svelte-language-server` | |
|
||||
| `.astro` | `astro-ls` | Needs Node.js and a TypeScript library. |
|
||||
| TS and HTML in Angular projects | `angular-language-server` (`ngserver`) | Only below `angular.json` or `node_modules/@angular/core`. |
|
||||
| All of the above | `oxlint` | Only below an `.oxlintrc.json`, `.oxlintrc.jsonc`, `oxlint.config.ts` or `oxlint.config.mts`. |
|
||||
| All of the above | `vscode-eslint-language-server` (ESLint) | Only below an ESLint configuration (`eslint.config.*`, `.eslintrc*` or `eslintConfig` in `package.json`); runs the project's own `eslint`. |
|
||||
|
||||
The TypeScript servers start for a workspace marked by `tsconfig.json`, `jsconfig.json` or `package.json`. Files outside any `tsconfig.json` / `jsconfig.json` are still registered with tsserver, so loose scripts get code insight too.
|
||||
|
||||
@@ -49,8 +47,7 @@ All servers, debuggers and formatters are listed in **Settings › Languages & F
|
||||
| `vtsls`, `typescript-language-server` | npm (`@vtsls/language-server`; `typescript-language-server` + `typescript@6`) |
|
||||
| `vue-language-server`, `svelte-language-server`, `astro-ls`, `angular-language-server` | npm |
|
||||
| `oxlint` | npm |
|
||||
| `tailwindcss-language-server` | npm (`@tailwindcss/language-server`) |
|
||||
| Prettier, oxfmt, Biome | npm |
|
||||
| Prettier, oxfmt | npm |
|
||||
| JavaScript Debugger (vscode-js-debug) | GitHub release (`microsoft/vscode-js-debug`) |
|
||||
|
||||
The Astro and Angular servers also run from the project's own `node_modules/.bin` when it has them.
|
||||
@@ -70,19 +67,14 @@ The Astro and Angular servers also run from the project's own `node_modules/.bin
|
||||
|
||||
- **Prettier** (**Settings › Languages & Frameworks › Prettier**) formats JavaScript, JSX, TypeScript, TSX, JSON, Vue, HTML, CSS, SCSS, Less, GraphQL, YAML and Markdown by default. The executable is found in the project's `node_modules`, then the managed installation, then `PATH`, unless you set **Prettier path**.
|
||||
- **oxfmt** (**Settings › Languages & Frameworks › oxfmt**) replaces Prettier for an enabled language in files below an oxfmt configuration (`.oxfmtrc.json`, `oxfmt.config.ts`), or when it is the selected provider.
|
||||
- **Biome** (**Settings › Languages & Frameworks › Biome**) replaces Prettier and oxfmt for JavaScript, JSX, TypeScript, TSX, JSON, CSS and GraphQL in files below a `biome.json` / `biome.jsonc` or an installed `@biomejs/biome` (unless the configuration sets `formatter.enabled` to `false`), or when it is the selected provider. It formats whole files and reads its own configuration.
|
||||
|
||||
On these pages, **Formatting provider** chooses between **Automatic (language server first)** and the tool itself, **Run on save** formats on save, and **Enabled languages** limits which languages the tool handles.
|
||||
|
||||
### Biome lint
|
||||
|
||||
In a Biome project, Biome's diagnostics show in the editor and the Problems tool window, and `⌥⏎` / `Alt+Enter` offers its quick fixes and suppressions. Biome's safe fixes (`source.fixAll.biome`) run with **Code › Code Cleanup** and, when **Settings › Tools › Actions on Save › Run code cleanup** is on, on save. When Biome's formatter is enabled, its fix-all formats the file too.
|
||||
On both pages, **Formatting provider** chooses between **Automatic (language server first)** and the tool itself, **Run on save** formats on save, and **Enabled languages** limits which languages the tool handles.
|
||||
|
||||
## Run and test
|
||||
|
||||
OpenIDEA detects run configurations when the project opens:
|
||||
|
||||
- One configuration per `package.json` script (`npm run build`, `pnpm run dev`, …), for the root package, nested packages and workspace members. Scripts named `test`, `jest`, `vitest` or `test:*`, and scripts that run `playwright test`, `node --test` or `mocha`, are test configurations.
|
||||
- One configuration per `package.json` script (`npm run build`, `pnpm run dev`, …), for the root package, nested packages and workspace members. Scripts named `test`, `jest`, `vitest` or `test:*`, and scripts that run `playwright test` or `node --test`, are test configurations.
|
||||
- `playwright test` (through `npx`) for a package with a `playwright.config.*` that no script runs.
|
||||
- One per task in `deno.json` / `deno.jsonc` (`deno task <name>`).
|
||||
|
||||
@@ -94,7 +86,7 @@ In `package.json`, the gutter shows run icons on each `scripts` entry to run or
|
||||
- Any other `.js` file runs with `node` (with `deno run` or `bun run` in a project with `deno.json` or `bun.lock`).
|
||||
- A `.ts` file runs with Node.js directly on 22.18+ / 23.6+, with `--experimental-strip-types` on 22.6–22.17 and 23.0–23.5, else through `tsx` or `ts-node`.
|
||||
|
||||
Jest, Vitest, Playwright Test, `node --test` and Mocha output is turned into the test tree, with **Rerun Failed Tests**. Playwright runs report through its `list` reporter unless the configuration names another; a test in the gutter runs by its line (`file:line`), and runs with several projects show each project under its file. `node --test` runs report through the IDE's reporter next to `spec`, added to `NODE_OPTIONS` (a script that chooses its own `--test-reporter` runs without the tree); single tests and reruns are selected by full name (`--test-name-pattern`). Mocha runs keep their reporter and load an IDE hook through `NODE_OPTIONS` that reports each test with its line; single tests and reruns use `--grep`, and in projects that test with Mocha or `node --test`, tests in `test/` get gutter icons whatever their file name. **Run with Coverage** works for scripts that run `vitest` or `jest` (Vitest needs a coverage provider such as `@vitest/coverage-v8`; the IDE offers to add it) and for `node` / `tsx` / `ts-node` runs through `c8`. See [Testing](/en/guide/testing) and [Coverage](/en/guide/coverage).
|
||||
Jest, Vitest, Playwright Test and `node --test` output is turned into the test tree, with **Rerun Failed Tests**. Playwright runs report through its `list` reporter unless the configuration names another; a test in the gutter runs by its line (`file:line`), and runs with several projects show each project under its file. `node --test` runs report through the IDE's reporter next to `spec`, added to `NODE_OPTIONS` (a script that chooses its own `--test-reporter` runs without the tree); single tests and reruns are selected by full name (`--test-name-pattern`). **Run with Coverage** works for scripts that run `vitest` or `jest` (Vitest needs a coverage provider such as `@vitest/coverage-v8`; the IDE offers to add it) and for `node` / `tsx` / `ts-node` runs through `c8`. See [Testing](/en/guide/testing) and [Coverage](/en/guide/coverage).
|
||||
|
||||
## Debugging
|
||||
|
||||
|
||||
@@ -297,14 +297,14 @@ launching as before.
|
||||
|
||||
## Running programs
|
||||
|
||||
| Function | What it does |
|
||||
| -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `Project::run_process(program, &args, stdin)` | Runs the pinned program in the project root and waits: `{ status, stdout, stderr }`, 4 MiB each. |
|
||||
| `host::run_command(&Command, Some(&project), stdin)` | API 1.3: the same, with environment variables added by `Command::env`. |
|
||||
| `host::run_captured(&Command, Some(&project), stdin, options)` | API 1.15: configurable output limit (up to 128 MiB per stream); errors explicitly if either stdout or stderr overflows. |
|
||||
| `host::start(&Command, Some(&project))` | API 1.3: a `Child` left running: `poll`, `write`, `close_stdin`, `wait`, `kill`. At most 8. |
|
||||
| `host::start_stream(&Command, Some(&project), options)` | API 1.15: lossless streaming with backpressure and bounded buffer, terminating with an explicit error on total overflow. |
|
||||
| `host::open_terminal(title, program, &args)` | A Terminal tab running the program (see [Views](/en/plugins/guides/views)). |
|
||||
| Function | What it does |
|
||||
| ------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------- |
|
||||
| `Project::run_process(program, &args, stdin)` | Runs the pinned program in the project root and waits: `{ status, stdout, stderr }`, 4 MiB each. |
|
||||
| `host::run_command(&Command, Some(&project), stdin)` | API 1.3: the same, with environment variables added by `Command::env`. |
|
||||
| `host::run_captured(&Command, Some(&project), stdin, options)` | API 1.15: configurable output limit (up to 128 MiB per stream); errors explicitly if either stdout or stderr overflows. |
|
||||
| `host::start(&Command, Some(&project))` | API 1.3: a `Child` left running: `poll`, `write`, `close_stdin`, `wait`, `kill`. At most 8. |
|
||||
| `host::start_stream(&Command, Some(&project), options)` | API 1.15: lossless streaming with backpressure and bounded buffer, terminating with an explicit error on total overflow.|
|
||||
| `host::open_terminal(title, program, &args)` | A Terminal tab running the program (see [Views](/en/plugins/guides/views)). |
|
||||
|
||||
```rust
|
||||
use openidea_plugin::host::{self, Command};
|
||||
|
||||
@@ -55,7 +55,7 @@ exclude = ["**/.git", "**/node_modules", "**/target", "**/dist"]
|
||||
| Plugins | Plugins |
|
||||
| Version Control | Commit; Confirmation; Directory Mappings; Issue Navigation; Log; Shelf; Git; GitHub |
|
||||
| Build, Execution, Deployment | CMake; Gradle; Maven; Console; Debugger (Data Views, Stepping); Python Debugger; Run/Debug; Run Targets; Deployment (Options) |
|
||||
| Languages & Frameworks | Language Servers; Go (Build Tags, Go Modules); Java; Markdown; Node.js; PHP; Python Interpreter; Prettier; oxfmt; Biome; Ruff; Ruby; Rust; TypeScript |
|
||||
| Languages & Frameworks | Language Servers; Go (Build Tags, Go Modules); Java; Markdown; Node.js; PHP; Python Interpreter; Prettier; oxfmt; Ruff; Ruby; Rust; TypeScript |
|
||||
| Tools | Agents (Chat); Terminal; Actions on Save; External Tools; SSH Configurations; MCP Server |
|
||||
| Security | Project Trust |
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ mise run dev
|
||||
|
||||
`setup` 在当前 worktree 中执行 `pnpm install`。`dev` 和 `dev:app` 都沿用原来的启动脚本,保留 worktree 隔离。使用 `mise run` 不需要在 shell 中激活 mise。
|
||||
|
||||
运行 `mise tasks` 可以查看全部任务。`mise run build` 构建前端,不生成桌面安装包;`mise run dogfood:build` 和 `mise run dogfood:install` 用于构建并在本地安装灰色图标的 dogfood 桌面版(与正式版共享设置和数据)。两者共用同一个实例,同一时间只能运行一个;较新的 dogfood 版写入的设置可能让较旧的正式版忽略整个设置文件。dogfood 版不会自动更新,需要更新时重新运行 `dogfood:install`。`mise run dogfood:remote <remote_name>` 在 **工具 › SSH 配置** 中指定的远程主机上构建并部署 `openidea-server`(`--clean` 可移除覆盖)。`mise run test` 运行 Vitest 和 `cargo test --workspace`;`mise run check` 先检查格式、代码规范、类型和未使用的代码,再运行这两套测试。两者都不需要 nextest 或插件的 WASM 目标。
|
||||
运行 `mise tasks` 可以查看全部任务。`mise run build` 构建前端,不生成桌面安装包;`mise run dogfood:build` 和 `mise run dogfood:install` 用于构建并在本地安装灰色图标的 dogfood 桌面版(与正式版共享设置和数据)。两者共用同一个实例,同一时间只能运行一个;较新的 dogfood 版写入的设置可能让较旧的正式版忽略整个设置文件。dogfood 版不会自动更新,需要更新时重新运行 `dogfood:install`。`mise run test` 运行 Vitest 和 `cargo test --workspace`;`mise run check` 先检查格式、代码规范、类型和未使用的代码,再运行这两套测试。两者都不需要 nextest 或插件的 WASM 目标。
|
||||
|
||||
## Worktree
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ description: "多光标与选区、行编辑、剪贴板历史、代码折叠、
|
||||
| **自动缩进行** | `⌃⌥I` | `Ctrl+Alt+I` |
|
||||
| **优化导入** | `⌃⌥O` | `Ctrl+Alt+O` |
|
||||
|
||||
**重新格式化代码** 格式化选区,没有选区时格式化整个文件,整体算一步撤销。格式化由文件的语言服务器或该语言配置的格式化工具完成(例如 Python 用 Ruff,Web 语言用 Prettier、oxfmt 或 Biome;在查找操作里搜 **使用 … 重新格式化** 可以指定工具)。**重新格式化文件…** 还能选择范围并顺便优化导入。
|
||||
**重新格式化代码** 格式化选区,没有选区时格式化整个文件,整体算一步撤销。格式化由文件的语言服务器或该语言配置的格式化工具完成(例如 Python 用 Ruff,Web 语言用 Prettier 或 oxfmt;在查找操作里搜 **使用 … 重新格式化** 可以指定工具)。**重新格式化文件…** 还能选择范围并顺便优化导入。
|
||||
|
||||
缩进等代码风格选项在 **设置 › 编辑器 › 代码样式** 中,每种语言一个页面。项目里的 `.editorconfig` 也会生效。
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ RSpec 有自己的配置类型(**RSpec 测试**)和检测到的 `rspec` 配
|
||||
| **重新运行**(在“运行”工具窗口中) | `⌘R` | `Ctrl+F5` |
|
||||
| **重新运行失败的测试** | — | — |
|
||||
|
||||
**重新运行失败的测试**(在“运行”工具窗口工具栏和“查找操作”中)只运行上一次失败的测试,会按各个工具自己的过滤语法生成命令。支持 Cargo、Jest / Vitest、Playwright、`node --test`、Mocha、pytest、Django、PHPUnit、Go、Maven / Gradle 和 .NET,以及插件接入的测试框架。
|
||||
**重新运行失败的测试**(在“运行”工具窗口工具栏和“查找操作”中)只运行上一次失败的测试,会按各个工具自己的过滤语法生成命令。支持 Cargo、Jest / Vitest、Playwright、`node --test`、pytest、Django、PHPUnit、Go、Maven / Gradle 和 .NET,以及插件接入的测试框架。
|
||||
|
||||
## 在代码和测试之间跳转
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ OpenIDEA 用一个小的定义文件 `languages/<id>.toml` 描述每种语言:
|
||||
一种语言可以配置多个服务器:
|
||||
|
||||
- **备选**(下表中写作 `a → b`):只运行第一个已安装的。例如 Python 默认用 basedpyright,只有它缺失时才退回 pyright、ty 或 pyrefly。在 **设置 › 语言和框架 › 语言服务器** 中可以指定其中一个,或选 **自动**(使用第一个可用的)。
|
||||
- **附加**(写作 `+ b`):和主服务器同时运行,通常只在用到它的项目中启用。带 Ruff 配置的项目里 Ruff 与 basedpyright 一起运行;带 oxlint 配置的项目里 oxlint 与 vtsls 一起运行;带 Stylelint 配置(`.stylelintrc*`、`stylelint.config.*` 或 `package.json` 中的 `stylelint`)的项目里 Stylelint 与 CSS、SCSS、Less 的服务器一起运行,使用项目自己的 `stylelint`(编辑器右键菜单中的 **修复 Stylelint 问题** 应用它的修复);带 Biome 配置或安装了 Biome 的项目里 Biome 与 JavaScript、TypeScript、JSON、CSS 和 GraphQL 的服务器一起运行;Angular、Laravel 和 Tailwind CSS 项目里分别加上 Angular、Laravel 和 Tailwind CSS 的服务器。
|
||||
- **附加**(写作 `+ b`):和主服务器同时运行,通常只在用到它的项目中启用。带 Ruff 配置的项目里 Ruff 与 basedpyright 一起运行;带 oxlint 配置的项目里 oxlint 与 vtsls 一起运行;Angular 和 Laravel 项目里分别加上 Angular 和 Laravel 的服务器。
|
||||
|
||||
## 安装语言服务器和调试器
|
||||
|
||||
@@ -86,92 +86,92 @@ IDE 安装工具从不需要 `sudo`。工具装在本地数据目录下 IDE 自
|
||||
|
||||
下表列出全部内置语言定义。**加粗** 的服务器和调试器可以在 IDE 中一键安装,其余需要自行安装(IDE 中的安装提示会说明方法)。"高亮"和"Tree-sitter"两列分别表示是否有即时高亮,以及是否有用于大纲和折叠的内置语法。
|
||||
|
||||
| 语言 | ID | 文件 | 高亮 | Tree-sitter | 语言服务器 | 调试器 |
|
||||
| ------------------- | ------------------ | ----------------------------------------------------------- | ---- | ----------- | ------------------------------------------------------------------------------------------------- | ------------------------ |
|
||||
| .env | `dotenv` | `.env` | 是 | — | — | — |
|
||||
| Arduino | `arduino` | `.ino` | 是 | 是 | arduino-language-server | — |
|
||||
| AsciiDoc | `asciidoc` | `.adoc`, `.asciidoc` | 是 | — | — | — |
|
||||
| Astro | `astro` | `.astro` | 是 | — | **astro-ls** + **oxlint** | — |
|
||||
| Batch | `bat` | `.bat`, `.cmd` | 是 | — | — | — |
|
||||
| C | `c` | `.c`, `.h` | 是 | 是 | **clangd** | lldb-dap |
|
||||
| C# | `csharp` | `.cs`, `.csx` | 是 | 是 | **csharp-ls** | **netcoredbg** |
|
||||
| C++ | `cpp` | `.cpp`, `.cc`, `.cxx`, `.c++`, `.hpp`, … | 是 | 是 | **clangd** | lldb-dap |
|
||||
| Clojure | `clojure` | `.clj`, `.cljs`, `.cljc`, `.cljd`, `.edn`, … | 是 | — | **clojure-lsp** | — |
|
||||
| CMake | `cmake` | `.cmake` | 是 | 是 | **neocmakelsp** → cmake-language-server | — |
|
||||
| CSS | `css` | `.css`, `.pcss`, `.postcss` | 是 | 是 | **vscode-css-language-server** + **biome** + **stylelint** | — |
|
||||
| D | `d` | `.d`, `.di` | 是 | — | serve-d | — |
|
||||
| Dart | `dart` | `.dart` | 是 | 是 | dart | dart |
|
||||
| Diff | `diff` | `.diff`, `.patch`, `.rej` | 是 | — | — | — |
|
||||
| Django Template | `django-html` | `.djhtml`, `templates/*.html`, `*.txt` | 是 | 是 | **vscode-html-language-server**, **djlsp** | — |
|
||||
| Dockerfile | `dockerfile` | `.dockerfile`, `.containerfile` | 是 | — | **dockerfile-language-server** | — |
|
||||
| Elixir | `elixir` | `.ex`, `.exs` | 是 | 是 | **elixir-ls** | **elixir-ls-debugger** |
|
||||
| ERB | `erb` | `.erb`, `.html.erb`, `.rhtml`, `.js.erb`, `.text.erb`, … | 是 | — | — | — |
|
||||
| Erlang | `erlang` | `.erl`, `.hrl`, `.escript`, `.app.src` | 是 | — | elp | — |
|
||||
| F# | `fsharp` | `.fs`, `.fsi`, `.fsx` | 是 | — | **fsautocomplete** | **netcoredbg** |
|
||||
| GDScript | `gdscript` | `.gd` | 是 | 是 | godot | godot |
|
||||
| Git Attributes | `gitattributes` | `.gitattributes` | — | — | — | — |
|
||||
| Go | `go` | `.go` | 是 | 是 | **gopls** | **delve** |
|
||||
| Go Module | `go.mod` | `go.mod` | 是 | — | **gopls** | — |
|
||||
| Go Workspace | `go.work` | `go.work` | 是 | — | **gopls** | — |
|
||||
| Godot Resource | `godot-resource` | `.tscn`, `.tres`, `.godot`, `.import` | 是 | — | — | — |
|
||||
| Godot Shader | `gdshader` | `.gdshader`, `.gdshaderinc` | 是 | — | — | — |
|
||||
| GraphQL | `graphql` | `.graphql`, `.graphqls`, `.gql` | 是 | 是 | **graphql-lsp** + **biome** | — |
|
||||
| Groovy | `groovy` | `.groovy`, `.gradle`, `.gvy`, `.gy`, `.gsh` | 是 | — | groovy-language-server | — |
|
||||
| Haskell | `haskell` | `.hs`, `.hs-boot`, `.hsig` | 是 | 是 | haskell-language-server | — |
|
||||
| HCL | `hcl` | `.hcl`, `.nomad`, `.pkr.hcl` | 是 | 是 | — | — |
|
||||
| HTML | `html` | `.html`, `.htm`, `.xhtml`, `.shtml`, `.html.tmpl` | 是 | 是 | **vscode-html-language-server** + **angular-language-server** | — |
|
||||
| HTTP Request | `http` | `.http`, `.rest` | 是 | — | — | — |
|
||||
| Ignore File | `ignore` | `.gitignore`, `.dockerignore` | — | — | — | — |
|
||||
| INI | `ini` | `.ini`, `.cfg`, `.conf`, `.cnf`, `.inf`, … | 是 | — | — | — |
|
||||
| Java | `java` | `.java` | 是 | 是 | **jdtls** → **java-analyzer** → **kmp-lsp** | **java-debug** |
|
||||
| JavaScript | `javascript` | `.js`, `.mjs`, `.cjs` | 是 | 是 | **vtsls** → **typescript-language-server** + **oxlint** + **biome** | **js-debug** |
|
||||
| JavaScript JSX | `javascriptreact` | `.jsx` | 是 | 是 | **vtsls** → **typescript-language-server** + **oxlint** + **biome** | **js-debug** |
|
||||
| JSON | `json` | `.json`, `.geojson`, `.topojson`, `.webmanifest`, `.har`, … | 是 | 是 | **vscode-json-language-server** + **biome** | — |
|
||||
| JSON with Comments | `jsonc` | `.jsonc`, `.code-workspace`, `.code-snippets` | 是 | 是 | **vscode-json-language-server** + **biome** | — |
|
||||
| JSP | `jsp` | `.jsp`, `.jspx`, `.jspf`, `.jsph`, `.tag`, … | 是 | — | — | — |
|
||||
| Julia | `julia` | `.jl` | 是 | — | julia-languageserver | — |
|
||||
| Kotlin | `kotlin` | `.kt`, `.kts` | 是 | 是 | **kotlin-lsp** → **kotlin-language-server** → **kmp-lsp** | **kotlin-debug-adapter** |
|
||||
| LaTeX | `latex` | `.tex`, `.ltx`, `.sty`, `.cls`, `.dtx`, … | 是 | — | **texlab** | — |
|
||||
| Less | `less` | `.less` | 是 | — | **vscode-css-language-server** + **stylelint** | — |
|
||||
| Log | `log` | `.log` | 是 | — | — | — |
|
||||
| Lua | `lua` | `.lua`, `.luau`, `.rockspec` | 是 | 是 | **lua-language-server** | — |
|
||||
| Makefile | `makefile` | `.mk`, `.mak`, `.make` | 是 | 是 | — | — |
|
||||
| Markdown | `markdown` | `.md`, `.markdown`, `.mdown`, `.mkd`, `.mkdn`, … | 是 | 是 | **marksman** | — |
|
||||
| Nix | `nix` | `.nix` | 是 | 是 | nil → nixd | — |
|
||||
| Objective-C | `objective-c` | `.m` | 是 | — | **clangd** | lldb-dap |
|
||||
| Objective-C++ | `objective-cpp` | `.mm` | 是 | — | **clangd** | lldb-dap |
|
||||
| OCaml | `ocaml` | `.ml`, `.mll`, `.mly` | 是 | 是 | ocamllsp | ocamlearlybird |
|
||||
| OCaml Interface | `ocaml.interface` | `.mli` | 是 | 是 | ocamllsp | — |
|
||||
| Perl | `perl` | `.pl`, `.pm`, `.pod`, `.psgi`, `.cgi` | 是 | — | **perlnavigator** | — |
|
||||
| PHP | `php` | `.php`, `.phtml`, `.php3`, `.php4`, `.php5`, … | 是 | 是 | **intelephense** → phpactor → **phoxite** + **laravel-lsp** | **php-debug** |
|
||||
| Plain Text | `plaintext` | `.txt`, `.text` | — | — | — | — |
|
||||
| PowerShell | `powershell` | `.ps1`, `.psm1`, `.psd1`, `.pssc`, `.psrc` | 是 | — | powershell-editor-services | — |
|
||||
| Prisma | `prisma` | `.prisma` | 是 | 是 | **prisma-language-server** | — |
|
||||
| Properties | `properties` | `.properties`, `.prefs` | 是 | — | — | — |
|
||||
| Protocol Buffers | `proto` | `.proto` | 是 | 是 | **buf** | — |
|
||||
| Python | `python` | `.py`, `.pyi`, `.pyw` | 是 | 是 | **basedpyright** → **pyright** → **ty** → **pyrefly** + **ruff** | **debugpy** |
|
||||
| R | `r` | `.r`, `.rprofile` | 是 | — | r-languageserver | — |
|
||||
| reStructuredText | `restructuredtext` | `.rst` | 是 | — | — | — |
|
||||
| Ruby | `ruby` | `.rb`, `.rake`, `.gemspec`, `.ru`, `.rbi`, … | 是 | 是 | **ruby-lsp** → **solargraph** | rdbg |
|
||||
| Rust | `rust` | `.rs` | 是 | 是 | **rust-analyzer** | **codelldb** |
|
||||
| Sass | `sass` | `.sass` | 是 | — | — | — |
|
||||
| Scala | `scala` | `.scala`, `.sc`, `.sbt`, `.mill` | 是 | 是 | metals | — |
|
||||
| SCSS | `scss` | `.scss` | 是 | — | **vscode-css-language-server** + **stylelint** | — |
|
||||
| Shell Script | `shellscript` | `.sh`, `.bash`, `.zsh`, `.ksh`, `.ash`, … | 是 | 是 | **bash-language-server** | **bash-debug** |
|
||||
| Slint | `slint` | `.slint` | 是 | — | **slint-lsp** | — |
|
||||
| SQL | `sql` | `.sql`, `.ddl`, `.dml`, `.psql`, `.pgsql`, … | 是 | — | **sqls** | — |
|
||||
| Svelte | `svelte` | `.svelte` | 是 | — | **svelte-language-server** + **oxlint** | — |
|
||||
| Swift | `swift` | `.swift`, `.swiftinterface` | 是 | 是 | sourcekit-lsp | lldb-dap |
|
||||
| Terraform | `terraform` | `.tf`, `.tofu`, `.tftest.hcl` | 是 | 是 | **terraform-ls** | — |
|
||||
| Terraform Variables | `terraform-vars` | `.tfvars` | 是 | 是 | **terraform-ls** | — |
|
||||
| TOML | `toml` | `.toml` | 是 | 是 | **taplo** | — |
|
||||
| TypeScript | `typescript` | `.ts`, `.mts`, `.cts` | 是 | 是 | **vtsls** → **typescript-language-server** + **angular-language-server** + **oxlint** + **biome** | **js-debug** |
|
||||
| TypeScript JSX | `typescriptreact` | `.tsx` | 是 | 是 | **vtsls** → **typescript-language-server** + **oxlint** + **biome** | **js-debug** |
|
||||
| Typst | `typst` | `.typ` | — | — | **tinymist** | — |
|
||||
| Vue | `vue` | `.vue` | 是 | — | **vue-language-server**, **vtsls** + **oxlint** | — |
|
||||
| XML | `xml` | `.xml`, `.xsd`, `.xsl`, `.xslt`, `.svg`, … | 是 | 是 | **lemminx** | — |
|
||||
| YAML | `yaml` | `.yaml`, `.yml` | 是 | 是 | **yaml-language-server** | — |
|
||||
| Zig | `zig` | `.zig`, `.zon` | 是 | 是 | **zls** | **codelldb** |
|
||||
| 语言 | ID | 文件 | 高亮 | Tree-sitter | 语言服务器 | 调试器 |
|
||||
| ------------------- | ------------------ | ----------------------------------------------------------- | ---- | ----------- | ------------------------------------------------------------------------------------- | ------------------------ |
|
||||
| .env | `dotenv` | `.env` | 是 | — | — | — |
|
||||
| Arduino | `arduino` | `.ino` | 是 | 是 | arduino-language-server | — |
|
||||
| AsciiDoc | `asciidoc` | `.adoc`, `.asciidoc` | 是 | — | — | — |
|
||||
| Astro | `astro` | `.astro` | 是 | — | **astro-ls** + **oxlint** | — |
|
||||
| Batch | `bat` | `.bat`, `.cmd` | 是 | — | — | — |
|
||||
| C | `c` | `.c`, `.h` | 是 | 是 | **clangd** | lldb-dap |
|
||||
| C# | `csharp` | `.cs`, `.csx` | 是 | 是 | **csharp-ls** | **netcoredbg** |
|
||||
| C++ | `cpp` | `.cpp`, `.cc`, `.cxx`, `.c++`, `.hpp`, … | 是 | 是 | **clangd** | lldb-dap |
|
||||
| Clojure | `clojure` | `.clj`, `.cljs`, `.cljc`, `.cljd`, `.edn`, … | 是 | — | **clojure-lsp** | — |
|
||||
| CMake | `cmake` | `.cmake` | 是 | 是 | **neocmakelsp** → cmake-language-server | — |
|
||||
| CSS | `css` | `.css`, `.pcss`, `.postcss` | 是 | 是 | **vscode-css-language-server** | — |
|
||||
| D | `d` | `.d`, `.di` | 是 | — | serve-d | — |
|
||||
| Dart | `dart` | `.dart` | 是 | 是 | dart | dart |
|
||||
| Diff | `diff` | `.diff`, `.patch`, `.rej` | 是 | — | — | — |
|
||||
| Django Template | `django-html` | `.djhtml`, `templates/*.html`, `*.txt` | 是 | 是 | **vscode-html-language-server**, **djlsp** | — |
|
||||
| Dockerfile | `dockerfile` | `.dockerfile`, `.containerfile` | 是 | — | **dockerfile-language-server** | — |
|
||||
| Elixir | `elixir` | `.ex`, `.exs` | 是 | 是 | **elixir-ls** | **elixir-ls-debugger** |
|
||||
| ERB | `erb` | `.erb`, `.html.erb`, `.rhtml`, `.js.erb`, `.text.erb`, … | 是 | — | — | — |
|
||||
| Erlang | `erlang` | `.erl`, `.hrl`, `.escript`, `.app.src` | 是 | — | elp | — |
|
||||
| F# | `fsharp` | `.fs`, `.fsi`, `.fsx` | 是 | — | **fsautocomplete** | **netcoredbg** |
|
||||
| GDScript | `gdscript` | `.gd` | 是 | 是 | godot | godot |
|
||||
| Git Attributes | `gitattributes` | `.gitattributes` | — | — | — | — |
|
||||
| Go | `go` | `.go` | 是 | 是 | **gopls** | **delve** |
|
||||
| Go Module | `go.mod` | `go.mod` | 是 | — | **gopls** | — |
|
||||
| Go Workspace | `go.work` | `go.work` | 是 | — | **gopls** | — |
|
||||
| Godot Resource | `godot-resource` | `.tscn`, `.tres`, `.godot`, `.import` | 是 | — | — | — |
|
||||
| Godot Shader | `gdshader` | `.gdshader`, `.gdshaderinc` | 是 | — | — | — |
|
||||
| GraphQL | `graphql` | `.graphql`, `.graphqls`, `.gql` | 是 | 是 | **graphql-lsp** | — |
|
||||
| Groovy | `groovy` | `.groovy`, `.gradle`, `.gvy`, `.gy`, `.gsh` | 是 | — | groovy-language-server | — |
|
||||
| Haskell | `haskell` | `.hs`, `.hs-boot`, `.hsig` | 是 | 是 | haskell-language-server | — |
|
||||
| HCL | `hcl` | `.hcl`, `.nomad`, `.pkr.hcl` | 是 | 是 | — | — |
|
||||
| HTML | `html` | `.html`, `.htm`, `.xhtml`, `.shtml`, `.html.tmpl` | 是 | 是 | **vscode-html-language-server** + **angular-language-server** | — |
|
||||
| HTTP Request | `http` | `.http`, `.rest` | 是 | — | — | — |
|
||||
| Ignore File | `ignore` | `.gitignore`, `.dockerignore` | — | — | — | — |
|
||||
| INI | `ini` | `.ini`, `.cfg`, `.conf`, `.cnf`, `.inf`, … | 是 | — | — | — |
|
||||
| Java | `java` | `.java` | 是 | 是 | **jdtls** → **java-analyzer** → **kmp-lsp** | **java-debug** |
|
||||
| JavaScript | `javascript` | `.js`, `.mjs`, `.cjs` | 是 | 是 | **vtsls** → **typescript-language-server** + **oxlint** | **js-debug** |
|
||||
| JavaScript JSX | `javascriptreact` | `.jsx` | 是 | 是 | **vtsls** → **typescript-language-server** + **oxlint** | **js-debug** |
|
||||
| JSON | `json` | `.json`, `.geojson`, `.topojson`, `.webmanifest`, `.har`, … | 是 | 是 | **vscode-json-language-server** | — |
|
||||
| JSON with Comments | `jsonc` | `.jsonc`, `.code-workspace`, `.code-snippets` | 是 | 是 | **vscode-json-language-server** | — |
|
||||
| JSP | `jsp` | `.jsp`, `.jspx`, `.jspf`, `.jsph`, `.tag`, … | 是 | — | — | — |
|
||||
| Julia | `julia` | `.jl` | 是 | — | julia-languageserver | — |
|
||||
| Kotlin | `kotlin` | `.kt`, `.kts` | 是 | 是 | **kotlin-lsp** → **kotlin-language-server** → **kmp-lsp** | **kotlin-debug-adapter** |
|
||||
| LaTeX | `latex` | `.tex`, `.ltx`, `.sty`, `.cls`, `.dtx`, … | 是 | — | **texlab** | — |
|
||||
| Less | `less` | `.less` | 是 | — | **vscode-css-language-server** | — |
|
||||
| Log | `log` | `.log` | 是 | — | — | — |
|
||||
| Lua | `lua` | `.lua`, `.luau`, `.rockspec` | 是 | 是 | **lua-language-server** | — |
|
||||
| Makefile | `makefile` | `.mk`, `.mak`, `.make` | 是 | 是 | — | — |
|
||||
| Markdown | `markdown` | `.md`, `.markdown`, `.mdown`, `.mkd`, `.mkdn`, … | 是 | 是 | **marksman** | — |
|
||||
| Nix | `nix` | `.nix` | 是 | 是 | nil → nixd | — |
|
||||
| Objective-C | `objective-c` | `.m` | 是 | — | **clangd** | lldb-dap |
|
||||
| Objective-C++ | `objective-cpp` | `.mm` | 是 | — | **clangd** | lldb-dap |
|
||||
| OCaml | `ocaml` | `.ml`, `.mll`, `.mly` | 是 | 是 | ocamllsp | ocamlearlybird |
|
||||
| OCaml Interface | `ocaml.interface` | `.mli` | 是 | 是 | ocamllsp | — |
|
||||
| Perl | `perl` | `.pl`, `.pm`, `.pod`, `.psgi`, `.cgi` | 是 | — | **perlnavigator** | — |
|
||||
| PHP | `php` | `.php`, `.phtml`, `.php3`, `.php4`, `.php5`, … | 是 | 是 | **intelephense** → phpactor → **phoxite** + **laravel-lsp** | **php-debug** |
|
||||
| Plain Text | `plaintext` | `.txt`, `.text` | — | — | — | — |
|
||||
| PowerShell | `powershell` | `.ps1`, `.psm1`, `.psd1`, `.pssc`, `.psrc` | 是 | — | powershell-editor-services | — |
|
||||
| Prisma | `prisma` | `.prisma` | 是 | 是 | **prisma-language-server** | — |
|
||||
| Properties | `properties` | `.properties`, `.prefs` | 是 | — | — | — |
|
||||
| Protocol Buffers | `proto` | `.proto` | 是 | 是 | **buf** | — |
|
||||
| Python | `python` | `.py`, `.pyi`, `.pyw` | 是 | 是 | **basedpyright** → **pyright** → **ty** → **pyrefly** + **ruff** | **debugpy** |
|
||||
| R | `r` | `.r`, `.rprofile` | 是 | — | r-languageserver | — |
|
||||
| reStructuredText | `restructuredtext` | `.rst` | 是 | — | — | — |
|
||||
| Ruby | `ruby` | `.rb`, `.rake`, `.gemspec`, `.ru`, `.rbi`, … | 是 | 是 | **ruby-lsp** → **solargraph** | rdbg |
|
||||
| Rust | `rust` | `.rs` | 是 | 是 | **rust-analyzer** | **codelldb** |
|
||||
| Sass | `sass` | `.sass` | 是 | — | — | — |
|
||||
| Scala | `scala` | `.scala`, `.sc`, `.sbt`, `.mill` | 是 | 是 | metals | — |
|
||||
| SCSS | `scss` | `.scss` | 是 | — | **vscode-css-language-server** | — |
|
||||
| Shell Script | `shellscript` | `.sh`, `.bash`, `.zsh`, `.ksh`, `.ash`, … | 是 | 是 | **bash-language-server** | **bash-debug** |
|
||||
| Slint | `slint` | `.slint` | 是 | — | **slint-lsp** | — |
|
||||
| SQL | `sql` | `.sql`, `.ddl`, `.dml`, `.psql`, `.pgsql`, … | 是 | — | **sqls** | — |
|
||||
| Svelte | `svelte` | `.svelte` | 是 | — | **svelte-language-server** + **oxlint** | — |
|
||||
| Swift | `swift` | `.swift`, `.swiftinterface` | 是 | 是 | sourcekit-lsp | lldb-dap |
|
||||
| Terraform | `terraform` | `.tf`, `.tofu`, `.tftest.hcl` | 是 | 是 | **terraform-ls** | — |
|
||||
| Terraform Variables | `terraform-vars` | `.tfvars` | 是 | 是 | **terraform-ls** | — |
|
||||
| TOML | `toml` | `.toml` | 是 | 是 | **taplo** | — |
|
||||
| TypeScript | `typescript` | `.ts`, `.mts`, `.cts` | 是 | 是 | **vtsls** → **typescript-language-server** + **angular-language-server** + **oxlint** | **js-debug** |
|
||||
| TypeScript JSX | `typescriptreact` | `.tsx` | 是 | 是 | **vtsls** → **typescript-language-server** + **oxlint** | **js-debug** |
|
||||
| Typst | `typst` | `.typ` | — | — | **tinymist** | — |
|
||||
| Vue | `vue` | `.vue` | 是 | — | **vue-language-server**, **vtsls** + **oxlint** | — |
|
||||
| XML | `xml` | `.xml`, `.xsd`, `.xsl`, `.xslt`, `.svg`, … | 是 | 是 | **lemminx** | — |
|
||||
| YAML | `yaml` | `.yaml`, `.yml` | 是 | 是 | **yaml-language-server** | — |
|
||||
| Zig | `zig` | `.zig`, `.zon` | 是 | 是 | **zls** | **codelldb** |
|
||||
|
||||
说明:
|
||||
|
||||
|
||||
@@ -7,18 +7,16 @@ OpenIDEA 打开 JavaScript(`.js`、`.mjs`、`.cjs`、`.jsx`)和 TypeScript
|
||||
|
||||
## 语言服务器
|
||||
|
||||
| 文件 | 服务器 | 说明 |
|
||||
| --------------------------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| JS、JSX、TS、TSX | `vtsls` | 默认的 TypeScript 服务器。 |
|
||||
| JS、JSX、TS、TSX | `typescript-language-server` | 备选:仅在未安装 `vtsls` 时使用。 |
|
||||
| `.vue` | `vue-language-server` + `vtsls` | Vue 的 hybrid 模式:`.vue` 中的 TypeScript 由加载了 `@vue/typescript-plugin` 的 `vtsls` 处理。 |
|
||||
| `.svelte` | `svelte-language-server` | |
|
||||
| `.astro` | `astro-ls` | 需要 Node.js 和 TypeScript 库。 |
|
||||
| Angular 项目中的 TS 和 HTML | `angular-language-server`(`ngserver`) | 只在 `angular.json` 或 `node_modules/@angular/core` 所在目录之下启用。 |
|
||||
| 以上全部 | `oxlint` | 只在存在 `.oxlintrc.json`、`.oxlintrc.jsonc`、`oxlint.config.ts` 或 `oxlint.config.mts` 的目录之下启用。 |
|
||||
| 以上全部 | `vscode-eslint-language-server`(ESLint) | 只在 ESLint 配置(`eslint.config.*`、`.eslintrc*` 或 `package.json` 中的 `eslintConfig`)所在目录之下启用,运行项目自己的 `eslint`。 |
|
||||
| JS、JSX、TS、TSX、JSON、CSS | `biome lsp-proxy`(Biome) | 只在 `biome.json` / `biome.jsonc` 所在目录或安装了 `@biomejs/biome` 的项目之下启用,运行项目自己的 `biome`。 |
|
||||
| 以上全部及 HTML、CSS | `tailwindcss-language-server`(Tailwind CSS) | 只在 `tailwind.config.*` 或依赖了 `tailwindcss` 的 `package.json` 所在目录之下启用:类名补全、悬停显示生成的 CSS、类名诊断。 |
|
||||
| 文件 | 服务器 | 说明 |
|
||||
| --------------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| JS、JSX、TS、TSX | `vtsls` | 默认的 TypeScript 服务器。 |
|
||||
| JS、JSX、TS、TSX | `typescript-language-server` | 备选:仅在未安装 `vtsls` 时使用。 |
|
||||
| `.vue` | `vue-language-server` + `vtsls` | Vue 的 hybrid 模式:`.vue` 中的 TypeScript 由加载了 `@vue/typescript-plugin` 的 `vtsls` 处理。 |
|
||||
| `.svelte` | `svelte-language-server` | |
|
||||
| `.astro` | `astro-ls` | 需要 Node.js 和 TypeScript 库。 |
|
||||
| Angular 项目中的 TS 和 HTML | `angular-language-server`(`ngserver`) | 只在 `angular.json` 或 `node_modules/@angular/core` 所在目录之下启用。 |
|
||||
| 以上全部 | `oxlint` | 只在存在 `.oxlintrc.json`、`.oxlintrc.jsonc`、`oxlint.config.ts` 或 `oxlint.config.mts` 的目录之下启用。 |
|
||||
| 以上全部 | `vscode-eslint-language-server`(ESLint) | 只在 ESLint 配置(`eslint.config.*`、`.eslintrc*` 或 `package.json` 中的 `eslintConfig`)所在目录之下启用,运行项目自己的 `eslint`。 |
|
||||
|
||||
TypeScript 服务器以 `tsconfig.json`、`jsconfig.json` 或 `package.json` 所在目录为工作区根。不属于任何 `tsconfig.json` / `jsconfig.json` 的文件也会注册给 tsserver,零散脚本同样有代码智能。
|
||||
|
||||
@@ -49,9 +47,7 @@ Vue、Astro 和 Angular 服务器也会使用这里选择的版本。TypeScript
|
||||
| `vtsls`、`typescript-language-server` | npm(`@vtsls/language-server`;`typescript-language-server` + `typescript@6`) |
|
||||
| `vue-language-server`、`svelte-language-server`、`astro-ls`、`angular-language-server` | npm |
|
||||
| `oxlint` | npm |
|
||||
| `tailwindcss-language-server` | npm(`@tailwindcss/language-server`) |
|
||||
| Prettier、oxfmt | npm |
|
||||
| Prettier、oxfmt、Biome | npm |
|
||||
| JavaScript 调试器(vscode-js-debug) | GitHub release(`microsoft/vscode-js-debug`) |
|
||||
|
||||
如果项目自己的 `node_modules/.bin` 里有 Astro 或 Angular 服务器,会优先使用项目里的。
|
||||
@@ -71,19 +67,14 @@ Vue、Astro 和 Angular 服务器也会使用这里选择的版本。TypeScript
|
||||
|
||||
- **Prettier**(**设置 › 语言和框架 › Prettier**)默认处理 JavaScript、JSX、TypeScript、TSX、JSON、Vue、HTML、CSS、SCSS、Less、GraphQL、YAML 和 Markdown。未设置 **Prettier 路径** 时,依次查找项目 `node_modules`、IDE 管理的安装、`PATH`。
|
||||
- **oxfmt**(**设置 › 语言和框架 › oxfmt**)在 oxfmt 配置文件(`.oxfmtrc.json`、`oxfmt.config.ts`)所在目录之下,或被选为格式化工具时,替代 Prettier 处理已启用的语言。
|
||||
- **Biome**(**设置 › 语言和框架 › Biome**)在 `biome.json` / `biome.jsonc` 所在目录或安装了 `@biomejs/biome` 的项目之下(配置里 `formatter.enabled` 为 `false` 时除外),或被选为格式化工具时,替代 Prettier 和 oxfmt 处理 JavaScript、JSX、TypeScript、TSX、JSON、CSS 和 GraphQL。它总是格式化整个文件,并读取自己的配置。
|
||||
|
||||
这些页面上,**格式化工具** 可选 **自动(优先语言服务器)** 或工具本身,**保存时运行** 控制保存时格式化,**启用的语言** 限定工具处理哪些语言。
|
||||
|
||||
### Biome 检查
|
||||
|
||||
在 Biome 项目中,Biome 的诊断显示在编辑器和“问题”工具窗口里,`⌥⏎` / `Alt+Enter` 提供它的快速修复和抑制。Biome 的安全修复(`source.fixAll.biome`)随 **代码 › 代码清理** 运行;开启 **设置 › 工具 › 保存时操作 › 运行代码清理** 后,保存时也会运行。Biome 的格式化器开启时,它的全部修复也会格式化文件。
|
||||
两个页面上,**格式化工具** 可选 **自动(优先语言服务器)** 或工具本身,**保存时运行** 控制保存时格式化,**启用的语言** 限定工具处理哪些语言。
|
||||
|
||||
## 运行与测试
|
||||
|
||||
打开项目时,OpenIDEA 会自动检测运行配置:
|
||||
|
||||
- 每个 `package.json` 脚本一个配置(`npm run build`、`pnpm run dev` 等),覆盖根包、嵌套包和 workspace 成员。名为 `test`、`jest`、`vitest` 或 `test:*` 的脚本,以及运行 `playwright test`、`node --test` 或 `mocha` 的脚本,是测试配置。
|
||||
- 每个 `package.json` 脚本一个配置(`npm run build`、`pnpm run dev` 等),覆盖根包、嵌套包和 workspace 成员。名为 `test`、`jest`、`vitest` 或 `test:*` 的脚本,以及运行 `playwright test` 或 `node --test` 的脚本,是测试配置。
|
||||
- 有 `playwright.config.*` 但没有脚本运行它的包:通过 `npx` 运行的 `playwright test`。
|
||||
- `deno.json` / `deno.jsonc` 中每个 task 一个配置(`deno task <name>`)。
|
||||
|
||||
@@ -95,7 +86,7 @@ Vue、Astro 和 Angular 服务器也会使用这里选择的版本。TypeScript
|
||||
- 其他 `.js` 文件用 `node` 运行(项目含 `deno.json` 或 `bun.lock` 时改用 `deno run` 或 `bun run`)。
|
||||
- `.ts` 文件在 Node.js 22.18+ / 23.6+ 上直接运行,在 22.6–22.17 和 23.0–23.5 上加 `--experimental-strip-types`,更早的版本则通过 `tsx` 或 `ts-node` 运行。
|
||||
|
||||
Jest、Vitest、Playwright Test、`node --test` 和 Mocha 的输出会解析成测试树,支持 **重新运行失败的测试**。Playwright 运行时使用它的 `list` 报告器(配置里指定了其他报告器时除外);从行号栏运行单个测试时按行号选择(`file:line`),有多个 project 的运行会在文件下按 project 分组。`node --test` 运行时,IDE 通过 `NODE_OPTIONS` 在 `spec` 旁加上自己的报告器(脚本自己指定了 `--test-reporter` 时不显示测试树);单个测试和重新运行按完整名称选择(`--test-name-pattern`)。Mocha 运行保留它自己的报告器,并通过 `NODE_OPTIONS` 加载 IDE 的钩子,逐个报告测试及其所在行;单个测试和重新运行使用 `--grep`,在用 Mocha 或 `node --test` 测试的项目里,`test/` 目录下的测试不论文件名都有行号栏图标。**使用覆盖率运行** 支持调用 `vitest` 或 `jest` 的脚本(Vitest 需要 `@vitest/coverage-v8` 之类的覆盖率 provider,缺失时 IDE 会提示添加),以及通过 `c8` 运行的 `node` / `tsx` / `ts-node`。详见[测试](/zh/guide/testing)和[覆盖率](/zh/guide/coverage)。
|
||||
Jest、Vitest、Playwright Test 和 `node --test` 的输出会解析成测试树,支持 **重新运行失败的测试**。Playwright 运行时使用它的 `list` 报告器(配置里指定了其他报告器时除外);从行号栏运行单个测试时按行号选择(`file:line`),有多个 project 的运行会在文件下按 project 分组。`node --test` 运行时,IDE 通过 `NODE_OPTIONS` 在 `spec` 旁加上自己的报告器(脚本自己指定了 `--test-reporter` 时不显示测试树);单个测试和重新运行按完整名称选择(`--test-name-pattern`)。**使用覆盖率运行** 支持调用 `vitest` 或 `jest` 的脚本(Vitest 需要 `@vitest/coverage-v8` 之类的覆盖率 provider,缺失时 IDE 会提示添加),以及通过 `c8` 运行的 `node` / `tsx` / `ts-node`。详见[测试](/zh/guide/testing)和[覆盖率](/zh/guide/coverage)。
|
||||
|
||||
## 调试
|
||||
|
||||
|
||||
@@ -254,14 +254,14 @@ register_plugin!(MyPlugin, run_target_validation);
|
||||
|
||||
## 运行程序
|
||||
|
||||
| 函数 | 作用 |
|
||||
| -------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
||||
| `Project::run_process(program, &args, stdin)` | 在项目根目录运行已固定的程序并等待结束:`{ status, stdout, stderr }`,各 4 MiB。 |
|
||||
| `host::run_command(&Command, Some(&project), stdin)` | API 1.3:同上,可用 `Command::env` 追加环境变量。 |
|
||||
| `host::run_captured(&Command, Some(&project), stdin, options)` | API 1.15:可配置输出上限(每个流最高 128 MiB),stdout 或 stderr 溢出时明确报错。 |
|
||||
| `host::start(&Command, Some(&project))` | API 1.3:保持运行的 `Child`:`poll`、`write`、`close_stdin`、`wait`、`kill`。最多 8 个。 |
|
||||
| `host::start_stream(&Command, Some(&project), options)` | API 1.15:基于管道背压的有界无损流式传输,超出总预算时明确报错并终止进程。 |
|
||||
| `host::open_terminal(title, program, &args)` | 运行该程序的终端标签页(见 [视图](/zh/plugins/guides/views))。 |
|
||||
| 函数 | 作用 |
|
||||
| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- |
|
||||
| `Project::run_process(program, &args, stdin)` | 在项目根目录运行已固定的程序并等待结束:`{ status, stdout, stderr }`,各 4 MiB。 |
|
||||
| `host::run_command(&Command, Some(&project), stdin)` | API 1.3:同上,可用 `Command::env` 追加环境变量。 |
|
||||
| `host::run_captured(&Command, Some(&project), stdin, options)` | API 1.15:可配置输出上限(每个流最高 128 MiB),stdout 或 stderr 溢出时明确报错。 |
|
||||
| `host::start(&Command, Some(&project))` | API 1.3:保持运行的 `Child`:`poll`、`write`、`close_stdin`、`wait`、`kill`。最多 8 个。 |
|
||||
| `host::start_stream(&Command, Some(&project), options)` | API 1.15:基于管道背压的有界无损流式传输,超出总预算时明确报错并终止进程。 |
|
||||
| `host::open_terminal(title, program, &args)` | 运行该程序的终端标签页(见 [视图](/zh/plugins/guides/views))。 |
|
||||
|
||||
```rust
|
||||
use openidea_plugin::host::{self, Command};
|
||||
|
||||
@@ -55,7 +55,7 @@ exclude = ["**/.git", "**/node_modules", "**/target", "**/dist"]
|
||||
| 插件 | 插件 |
|
||||
| 版本控制 | 提交;确认;目录映射;问题导航;日志;搁置;Git;GitHub |
|
||||
| 构建、执行、部署 | CMake;Gradle;Maven;控制台;调试器(数据视图、单步执行);Python 调试器;运行/调试;运行目标;部署(选项) |
|
||||
| 语言和框架 | 语言服务器;Go(构建标签、Go 模块);Java;Markdown;Node.js;PHP;Python 解释器;Prettier;oxfmt;Biome;Ruff;Ruby;Rust;TypeScript |
|
||||
| 语言和框架 | 语言服务器;Go(构建标签、Go 模块);Java;Markdown;Node.js;PHP;Python 解释器;Prettier;oxfmt;Ruff;Ruby;Rust;TypeScript |
|
||||
| 工具 | 智能体(聊天);终端;保存时操作;外部工具;SSH 配置;MCP 服务器 |
|
||||
| 安全 | 项目信任 |
|
||||
|
||||
|
||||
@@ -73,8 +73,6 @@ const initialSkills: AgentSkillState[] = [
|
||||
alsoIn: ["claudeWorkspace"],
|
||||
userInvocable: true,
|
||||
disableModelInvocation: false,
|
||||
contextFork: true,
|
||||
paths: ["src/**/*.tsx", "e2e/*.spec.ts"],
|
||||
valid: true,
|
||||
warnings: [],
|
||||
},
|
||||
@@ -328,8 +326,6 @@ test("manages multi-level skills in Settings and per-session overrides via Compo
|
||||
const sessionPopup = page.getByRole("dialog", { name: "Session Skills" });
|
||||
await expect(sessionPopup).toBeVisible();
|
||||
await expect(sessionPopup).toContainText("verify");
|
||||
await expect(sessionPopup).toContainText("fork");
|
||||
await expect(sessionPopup).toContainText("paths");
|
||||
await expect(sessionPopup).toContainText("impeccable");
|
||||
await expect(sessionPopup).toContainText("Plugins");
|
||||
await expect(sessionPopup).toContainText("release-notes");
|
||||
@@ -356,12 +352,9 @@ test("manages multi-level skills in Settings and per-session overrides via Compo
|
||||
await expect(settingsDialog).toBeVisible();
|
||||
await expect(settingsDialog.getByRole("heading", { name: "Skills" })).toBeVisible();
|
||||
await expect(settingsDialog.getByTitle(".claude/skills").first()).toHaveText("Claude Code");
|
||||
await expect(settingsDialog.getByText("context: fork")).toBeVisible();
|
||||
await expect(settingsDialog.getByText("paths (2)")).toBeVisible();
|
||||
|
||||
await settingsDialog.getByRole("button", { name: /^verify/ }).click();
|
||||
await expect(settingsDialog.getByText("Claude Code (.claude/skills)")).toBeVisible();
|
||||
await expect(settingsDialog.getByText("src/**/*.tsx, e2e/*.spec.ts")).toBeVisible();
|
||||
await expect(settingsDialog.getByText("SKILL.md is valid")).toBeVisible();
|
||||
|
||||
await settingsDialog.getByRole("tab", { name: /Plugins/ }).click();
|
||||
|
||||
@@ -18,27 +18,18 @@ test("keeps breakpoint details editable when the dialog gets narrow", async ({ w
|
||||
const list = dialog.getByRole("listbox", { name: "All breakpoints" });
|
||||
const condition = dialog.locator('input[aria-label="Condition"]');
|
||||
await expect(condition).toHaveValue("amount > 100");
|
||||
const actions = dialog.getByRole("group", { name: "Actions", exact: true });
|
||||
await expect(actions).toBeVisible();
|
||||
await expect(dialog.getByText("Condition", { exact: true })).toHaveCSS("font-size", "13px");
|
||||
await expect(dialog.getByText("Hit count", { exact: true })).toHaveCSS("font-size", "13px");
|
||||
await expect.poll(async () => (await condition.boundingBox())?.width ?? 0).toBeGreaterThanOrEqual(240);
|
||||
await expect(dialog.getByRole("button", { name: "Done", exact: true })).toBeInViewport({ ratio: 1 });
|
||||
await condition.fill("amount > 250");
|
||||
await actions.getByRole("checkbox", { name: '"Breakpoint hit" message', exact: true }).check();
|
||||
await actions.getByRole("checkbox", { name: "Evaluate and log", exact: true }).check();
|
||||
const log = actions.getByRole("textbox", { name: "Evaluate and log", exact: true });
|
||||
await log.fill("total: {amount}");
|
||||
const temporary = actions.getByRole("checkbox", { name: "Remove once hit", exact: true });
|
||||
await temporary.check();
|
||||
await dialog.getByRole("checkbox", { name: "Evaluate and log", exact: true }).check();
|
||||
await dialog.getByRole("textbox", { name: "Evaluate and log", exact: true }).fill("total: {amount}");
|
||||
const first = list.getByRole("option", { name: /CheckInternationalSettlementBeforeDispatch\.java:8/ });
|
||||
await expect(first.getByText(":8", { exact: true })).toBeInViewport({ ratio: 1 });
|
||||
await list.getByRole("option", { name: /Receipt\.java:5/ }).click();
|
||||
await expect(condition).toHaveValue("");
|
||||
await first.click();
|
||||
await expect(condition).toHaveValue("amount > 250");
|
||||
await expect(log).toHaveValue("total: {amount}");
|
||||
await expect(temporary).toBeChecked();
|
||||
await expect(dialog.getByRole("textbox", { name: "Evaluate and log", exact: true })).toHaveValue("total: {amount}");
|
||||
|
||||
await page.setViewportSize({ width: 1080, height: 760 });
|
||||
const divider = dialog.locator('[data-separator][aria-orientation="vertical"]');
|
||||
|
||||
@@ -715,58 +715,6 @@ test("rename keeps the typed name, uses the editor font and shows long preview n
|
||||
await expect.poll(() => ipcCalls(page, "apply_workspace_edit")).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("intentions separate quick fixes from other actions and navigate across the divider", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
const editor = await openSample(page);
|
||||
const fix = "Correct the Order type";
|
||||
const refactor = "Extract the order value";
|
||||
await page.evaluate(
|
||||
({ file, edit, fix, refactor }) => {
|
||||
const action = (title: string, kind: string, newText: string) => ({
|
||||
title,
|
||||
kind,
|
||||
isPreferred: false,
|
||||
disabledReason: null,
|
||||
edit: { files: [{ kind: "edit", path: file, edits: [{ range: edit, new_text: newText }] }] },
|
||||
command: null,
|
||||
data: null,
|
||||
server: 1,
|
||||
});
|
||||
window.__ipc.handlers.lsp_code_actions = () => [
|
||||
action(refactor, "refactor.extract", "ExtractedOrder"),
|
||||
action(fix, "quickfix", "CorrectOrder"),
|
||||
];
|
||||
window.__ipc.handlers.lsp_execute_code_action = () => [];
|
||||
},
|
||||
{ file: FILE, edit: range(20, 19, 24), fix, refactor },
|
||||
);
|
||||
await caretAt(editor, page, "val order: Order", "Order ");
|
||||
await page.keyboard.press("Alt+Enter");
|
||||
|
||||
const popup = page.getByRole("dialog", { name: "Intentions", exact: true });
|
||||
const list = popup.getByRole("listbox", { name: "Intentions" });
|
||||
const divider = list.locator("[class*=listDivider]");
|
||||
const preview = popup.locator('[aria-label="Preview"] pre');
|
||||
await expect(list.getByRole("option", { name: fix })).toBeVisible();
|
||||
await page.keyboard.type("order");
|
||||
await expect(list.getByRole("option")).toHaveText([fix, refactor]);
|
||||
await expect(divider).toHaveCount(1);
|
||||
await expect(list.getByRole("option", { name: fix })).toHaveAttribute("aria-selected", "true");
|
||||
await expect(preview).toContainText("CorrectOrder");
|
||||
await list.press("ArrowDown");
|
||||
await expect(list.getByRole("option", { name: refactor })).toHaveAttribute("aria-selected", "true");
|
||||
await expect(preview).toContainText("ExtractedOrder");
|
||||
|
||||
for (const _character of "order") await list.press("Backspace");
|
||||
await page.keyboard.type("extract");
|
||||
await expect(list.getByRole("option")).toHaveText([refactor]);
|
||||
await expect(divider).toHaveCount(0);
|
||||
await list.press("Enter");
|
||||
await expect(popup).toBeHidden();
|
||||
await expect.poll(() => ipcCalls(page, "lsp_execute_code_action")).toHaveLength(1);
|
||||
});
|
||||
|
||||
test("intention previews fit narrow windows and wrap long code lines", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1600, height: 900 });
|
||||
const editor = await openSample(page);
|
||||
|
||||
@@ -4,124 +4,63 @@ const amountName = "regionalSettlementAmountFromExternalProcessorBeforeRounding"
|
||||
const routingName = "settlementRoutingReferenceForCrossBorderReconciliation";
|
||||
const routingText = "APR-2026 / eu-west / batch-701 / settlement complete";
|
||||
const routingValue = "'" + routingText + "'";
|
||||
const invalidValueMessage = "The settlement amount must be a valid decimal expression.";
|
||||
|
||||
test.describe("a paused session with editable values", () => {
|
||||
test.beforeEach(async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1220, height: 760 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(
|
||||
async ({ amountName, routingName, routingValue, invalidValueMessage }) => {
|
||||
const debugModule = "/src/features/debugger/state.ts";
|
||||
const layoutModule = "/src/workbench/toolwindows/store.ts";
|
||||
const servicesModule = "/src/workbench/contributions.ts";
|
||||
const { adoptSession } = await import(/* @vite-ignore */ debugModule);
|
||||
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
|
||||
const { toolWindowService } = await import(/* @vite-ignore */ servicesModule);
|
||||
const h = window.__ipc.handlers;
|
||||
let amountValue = "47.74";
|
||||
const amount = () => ({
|
||||
name: amountName,
|
||||
value: amountValue,
|
||||
typeName: "float",
|
||||
variablesReference: 0,
|
||||
evaluateName: amountName,
|
||||
});
|
||||
h.debug_scopes = () => [{ name: "Locals", variablesReference: 100, expensive: false }];
|
||||
h.debug_variables = () => [
|
||||
amount(),
|
||||
{ name: routingName, value: routingValue, typeName: "str", variablesReference: 0, evaluateName: routingName },
|
||||
];
|
||||
h.debug_set_variable = ({ value }) => {
|
||||
if (value === "invalid") throw { kind: "invalid", message: invalidValueMessage, detail: null };
|
||||
amountValue = String(value);
|
||||
return amount();
|
||||
};
|
||||
adoptSession(91, {
|
||||
name: "Checkout",
|
||||
adapter: "debugpy",
|
||||
status: "paused",
|
||||
selectedFrame: 11,
|
||||
frames: [{ id: 11, name: "checkout", path: null, line: 0, column: 0, presentationHint: null }],
|
||||
});
|
||||
moveToolWindow("debug", "right");
|
||||
setToolWindowSize("right", 390);
|
||||
toolWindowService().show("debug", true);
|
||||
},
|
||||
{ amountName, routingName, routingValue, invalidValueMessage },
|
||||
);
|
||||
|
||||
const debug = page.getByRole("region", { name: "Debug", exact: true });
|
||||
await debug.getByRole("tab", { name: "Threads & Variables", exact: true }).click();
|
||||
});
|
||||
|
||||
test("keeps values and their full-value action readable in a narrow debugger", async ({ workbench: page }) => {
|
||||
const debug = page.getByRole("region", { name: "Debug", exact: true });
|
||||
const amount = debug.getByText("47.74", { exact: true });
|
||||
await expect
|
||||
.poll(() => amount.evaluate((el) => el.clientWidth > 0 && el.scrollWidth <= el.clientWidth + 1))
|
||||
.toBe(true);
|
||||
const routing = debug.getByRole("treeitem").filter({ hasText: routingName });
|
||||
const show = routing.getByTitle("Show", { exact: true });
|
||||
await expect(show).toBeInViewport({ ratio: 1 });
|
||||
await show.click();
|
||||
const dialog = page.getByRole("dialog", { name: `Value of ${routingName}` });
|
||||
await expect(dialog.getByText(routingText, { exact: true })).toBeVisible();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(dialog).toBeHidden();
|
||||
|
||||
await page.setViewportSize({ width: 1640, height: 760 });
|
||||
await page.evaluate(async () => {
|
||||
test("keeps values and their full-value action readable in a narrow debugger", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1220, height: 760 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(
|
||||
async ({ amountName, routingName, routingValue }) => {
|
||||
const debugModule = "/src/features/debugger/state.ts";
|
||||
const layoutModule = "/src/workbench/toolwindows/store.ts";
|
||||
const { moveToolWindow } = await import(/* @vite-ignore */ layoutModule);
|
||||
moveToolWindow("debug", "bottom");
|
||||
});
|
||||
await expect(show).toBeHidden();
|
||||
await expect
|
||||
.poll(() =>
|
||||
routing.getByText(routingValue, { exact: true }).evaluate((el) => el.scrollWidth <= el.clientWidth + 1),
|
||||
)
|
||||
.toBe(true);
|
||||
});
|
||||
const servicesModule = "/src/workbench/contributions.ts";
|
||||
const { adoptSession } = await import(/* @vite-ignore */ debugModule);
|
||||
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
|
||||
const { toolWindowService } = await import(/* @vite-ignore */ servicesModule);
|
||||
const h = window.__ipc.handlers;
|
||||
h.debug_scopes = () => [{ name: "Locals", variablesReference: 100, expensive: false }];
|
||||
h.debug_variables = () => [
|
||||
{ name: amountName, value: "47.74", typeName: "float", variablesReference: 0, evaluateName: amountName },
|
||||
{ name: routingName, value: routingValue, typeName: "str", variablesReference: 0, evaluateName: routingName },
|
||||
];
|
||||
adoptSession(91, {
|
||||
name: "Checkout",
|
||||
adapter: "debugpy",
|
||||
status: "paused",
|
||||
selectedFrame: 11,
|
||||
frames: [{ id: 11, name: "checkout", path: null, line: 0, column: 0, presentationHint: null }],
|
||||
});
|
||||
moveToolWindow("debug", "right");
|
||||
setToolWindowSize("right", 390);
|
||||
toolWindowService().show("debug", true);
|
||||
},
|
||||
{ amountName, routingName, routingValue },
|
||||
);
|
||||
|
||||
test("keeps the variable label and input in place when editing a value", async ({ workbench: page }) => {
|
||||
const debug = page.getByRole("region", { name: "Debug", exact: true });
|
||||
const row = debug.getByRole("treeitem").filter({ hasText: amountName });
|
||||
const name = row.getByText(amountName, { exact: true });
|
||||
await row.click();
|
||||
const nameBefore = (await name.boundingBox())!;
|
||||
const equal = row.getByText("=", { exact: true });
|
||||
const equalBefore = (await equal.boundingBox())!;
|
||||
const color = await name.evaluate((el) => getComputedStyle(el).color);
|
||||
const debug = page.getByRole("region", { name: "Debug", exact: true });
|
||||
await debug.getByRole("tab", { name: "Threads & Variables", exact: true }).click();
|
||||
const amount = debug.getByText("47.74", { exact: true });
|
||||
await expect
|
||||
.poll(() => amount.evaluate((el) => el.clientWidth > 0 && el.scrollWidth <= el.clientWidth + 1))
|
||||
.toBe(true);
|
||||
const routing = debug.getByRole("treeitem").filter({ hasText: routingName });
|
||||
const show = routing.getByTitle("Show", { exact: true });
|
||||
await expect(show).toBeInViewport({ ratio: 1 });
|
||||
await show.click();
|
||||
const dialog = page.getByRole("dialog", { name: `Value of ${routingName}` });
|
||||
await expect(dialog.getByText(routingText, { exact: true })).toBeVisible();
|
||||
await page.keyboard.press("Escape");
|
||||
await expect(dialog).toBeHidden();
|
||||
|
||||
await page.keyboard.press("F2");
|
||||
const input = row.getByRole("textbox", { name: `New value of ${amountName}` });
|
||||
await expect(input).toBeFocused();
|
||||
await expect(input).toHaveValue("47.74");
|
||||
await expect(name).toHaveCSS("color", color);
|
||||
expect((await name.boundingBox())!.x).toBeCloseTo(nameBefore.x, 0);
|
||||
expect((await equal.boundingBox())!.x).toBeCloseTo(equalBefore.x, 0);
|
||||
await expect(row.locator("svg")).toHaveCount(1);
|
||||
|
||||
await input.fill("invalid");
|
||||
await input.press("Enter");
|
||||
await expect(input).toHaveAttribute("aria-invalid", "true");
|
||||
await expect(input).toHaveAttribute("title", invalidValueMessage);
|
||||
await expect(input).toBeInViewport({ ratio: 1 });
|
||||
expect((await input.boundingBox())!.width).toBeGreaterThan(60);
|
||||
expect((await equal.boundingBox())!.x).toBeCloseTo(equalBefore.x, 0);
|
||||
|
||||
await input.press("Escape");
|
||||
await expect(input).toBeHidden();
|
||||
await expect(row).toContainText("47.74");
|
||||
|
||||
await page.keyboard.press("F2");
|
||||
await expect(input).toHaveValue("47.74");
|
||||
await input.fill("48.25");
|
||||
await input.press("Enter");
|
||||
await expect(input).toBeHidden();
|
||||
await expect(row).toContainText("48.25");
|
||||
await page.setViewportSize({ width: 1640, height: 760 });
|
||||
await page.evaluate(async () => {
|
||||
const layoutModule = "/src/workbench/toolwindows/store.ts";
|
||||
const { moveToolWindow } = await import(/* @vite-ignore */ layoutModule);
|
||||
moveToolWindow("debug", "bottom");
|
||||
});
|
||||
await expect(show).toBeHidden();
|
||||
await expect
|
||||
.poll(() => routing.getByText(routingValue, { exact: true }).evaluate((el) => el.scrollWidth <= el.clientWidth + 1))
|
||||
.toBe(true);
|
||||
});
|
||||
|
||||
test("keeps a decimal value legible beside a long runtime type", async ({ workbench: page }) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { EditorView } from "@codemirror/view";
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
async function openChain(page: Page) {
|
||||
await page.evaluate(async () => {
|
||||
@@ -46,70 +46,6 @@ test("a narrow diff keeps navigation, settings and the difference count visible"
|
||||
await expect(toolbar).toContainText("1 of 1 differences");
|
||||
});
|
||||
|
||||
test("revision titles keep both filenames in view when the diff divider moves", async ({ workbench: page }) => {
|
||||
const leftName = "OrderRoutes.ts";
|
||||
const rightName = "OrdersRoutes.ts";
|
||||
const directory = "services/customer-orders/fulfillment/warehouse-routing/primary";
|
||||
await page.setViewportSize({ width: 800, height: 650 });
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(
|
||||
async ({ directory, leftName, rightName }) => {
|
||||
const inputPath = "/src/features/vcs/diffInput.ts";
|
||||
const layoutPath = "/src/workbench/toolwindows/store.ts";
|
||||
const { openDiff } = await import(inputPath);
|
||||
const { hideAllToolWindows } = await import(layoutPath);
|
||||
const leftPath = `/dev/acme-api/${directory}/${leftName}`;
|
||||
const rightPath = `/dev/acme-api/${directory}/${rightName}`;
|
||||
window.__ipc.handlers.vcs_file_at = (args) =>
|
||||
args.rev === "7b70e02c" ? "export const region = 'east';\r\n" : "export const region = 'west';\n";
|
||||
window.__ipc.handlers.vcs_file_mode = () => "100644";
|
||||
hideAllToolWindows();
|
||||
localStorage.setItem("openidea.vcs.diffOptions", JSON.stringify({ mode: "split", alignChanges: false }));
|
||||
await openDiff({
|
||||
path: rightPath,
|
||||
left: { type: "rev", rev: "7b70e02c", path: leftPath },
|
||||
right: { type: "rev", rev: "a8c5f31d", path: rightPath },
|
||||
});
|
||||
},
|
||||
{ directory, leftName, rightName },
|
||||
);
|
||||
const left = page.getByTitle(/^7b70e02c .*OrderRoutes\.ts$/);
|
||||
const right = page.getByTitle(/^a8c5f31d .*OrdersRoutes\.ts$/);
|
||||
const filenamesFit = async () => {
|
||||
for (const [title, filename] of [
|
||||
[left, leftName],
|
||||
[right, rightName],
|
||||
] as const) {
|
||||
await expect(title).toBeVisible();
|
||||
expect(await title.getAttribute("title")).toContain(`${directory}/${filename}`);
|
||||
const text = title.locator("span").filter({ hasText: filename }).last();
|
||||
expect(
|
||||
await text.evaluate((el, filename) => {
|
||||
const node = el.firstChild!;
|
||||
const range = document.createRange();
|
||||
range.setStart(node, (node.textContent ?? "").length - filename.length);
|
||||
range.setEnd(node, (node.textContent ?? "").length);
|
||||
const bounds = range.getBoundingClientRect();
|
||||
const clip = el.getBoundingClientRect();
|
||||
return bounds.left >= clip.left - 1 && bounds.right <= clip.right + 1;
|
||||
}, filename),
|
||||
`${filename} is visible within its revision label`,
|
||||
).toBe(true);
|
||||
}
|
||||
};
|
||||
await filenamesFit();
|
||||
|
||||
const divider = page.getByRole("separator", { name: "Resize diff panes" });
|
||||
const { x, y, width, height } = (await divider.boundingBox())!;
|
||||
const leftWidth = (await left.boundingBox())!.width;
|
||||
await page.mouse.move(x + width / 2, y + height / 2);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(x + width / 2 - 96, y + height / 2, { steps: 4 });
|
||||
await page.mouse.up();
|
||||
await expect.poll(async () => (await left.boundingBox())!.width).toBeLessThan(leftWidth - 60);
|
||||
await filenamesFit();
|
||||
});
|
||||
|
||||
test("a medium-width diff keeps its full status beside the viewer tools", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 490, height: 650 });
|
||||
await page.evaluate(async () => {
|
||||
|
||||
@@ -526,7 +526,7 @@ test("Markdown preview keeps following find and edits after scrolling the source
|
||||
await content.focus();
|
||||
await page.keyboard.press("Meta+a");
|
||||
await page.keyboard.insertText("- **$`v_0`$ Flat wings.**");
|
||||
await expect(preview.locator("strong [data-math-svg] > svg")).toHaveAttribute("aria-label", "v_0");
|
||||
await expect(preview.locator("strong .katex annotation")).toHaveText("v_0");
|
||||
});
|
||||
|
||||
test("Markdown preview aligns Mermaid diagrams to their container align attribute", async ({ workbench: page }) => {
|
||||
|
||||
@@ -69,49 +69,3 @@ test("the bottom single row keeps a long selected tab visible alongside the hidd
|
||||
await pane.getByRole("tab", { name: shortFile, exact: true }).press("End");
|
||||
await expectCloseToFit(tab);
|
||||
});
|
||||
|
||||
test("same-name tabs keep the filename beside a shortened directory", async ({ workbench: page }) => {
|
||||
const filename = "AllocationRule.ts";
|
||||
const first = "qa";
|
||||
const second = "backoffice-reconciliation";
|
||||
await openSplit(page, [`${first}/${filename}`, `${second}/${filename}`], "top");
|
||||
await page.setViewportSize({ width: 900, height: 760 });
|
||||
|
||||
const pane = page.locator("section[data-pane-id]").filter({
|
||||
has: page.getByRole("tab").filter({ hasText: second }),
|
||||
});
|
||||
const selected = pane.getByRole("tab").filter({ hasText: second });
|
||||
await expect(selected).toHaveText(`${second}/${filename}`);
|
||||
await expectCloseToFit(selected);
|
||||
const directory = selected.getByText(`${second}/`, { exact: true });
|
||||
const name = selected.getByText(filename, { exact: true });
|
||||
await expect.poll(() => directory.evaluate((el) => el.clientWidth > 0 && el.scrollWidth > el.clientWidth)).toBe(true);
|
||||
await expect
|
||||
.poll(() =>
|
||||
name.evaluate((el) => {
|
||||
const text = document.createRange();
|
||||
text.selectNodeContents(el);
|
||||
return el.getBoundingClientRect().width >= text.getBoundingClientRect().width;
|
||||
}),
|
||||
)
|
||||
.toBe(true);
|
||||
|
||||
await pane.getByRole("button", { name: "Show Hidden Tabs" }).click();
|
||||
const picker = page.getByRole("grid", { name: "Hidden Editor Tabs" });
|
||||
await expect(picker.getByRole("gridcell").filter({ hasText: `${first}/${filename}` })).toBeVisible();
|
||||
await page.keyboard.press("Enter");
|
||||
const firstTab = pane.getByRole("tab").filter({ hasText: first });
|
||||
await expectCloseToFit(firstTab);
|
||||
await expect
|
||||
.poll(() =>
|
||||
firstTab.getByText(`${first}/`, { exact: true }).evaluate((el) => {
|
||||
const text = document.createRange();
|
||||
text.selectNodeContents(el);
|
||||
return Math.abs(el.clientWidth - text.getBoundingClientRect().width);
|
||||
}),
|
||||
)
|
||||
.toBeLessThanOrEqual(1);
|
||||
|
||||
await firstTab.locator("..").getByRole("button", { name: "Close Tab", exact: true }).click();
|
||||
await expect(page.getByRole("tab", { name: filename, exact: true })).toHaveAttribute("aria-selected", "true");
|
||||
});
|
||||
@@ -117,7 +117,7 @@ test("fits a wide graph and saved columns without horizontal scrolling", async (
|
||||
expect(await list.evaluate((element) => element.scrollLeft)).toBe(0);
|
||||
});
|
||||
|
||||
test("keeps expanded ref names visible when a long commit subject competes for space", async ({ workbench: page }) => {
|
||||
test("keeps ref names visible when a long commit subject competes for space", async ({ workbench: page }) => {
|
||||
const branch = "origin/feature/workspace-settings";
|
||||
const tag = "v2.1";
|
||||
const summary = "Keep workspace settings and commit references visible ".repeat(4).trim();
|
||||
@@ -127,7 +127,7 @@ test("keeps expanded ref names visible when a long commit subject competes for s
|
||||
const options = "/src/features/vcs/logOptions.ts";
|
||||
const { useGitLog } = await import(/* @vite-ignore */ log);
|
||||
const { useLogOptions } = await import(/* @vite-ignore */ options);
|
||||
useLogOptions.setState({ tagNames: true, compactRefs: false });
|
||||
useLogOptions.setState({ tagNames: true });
|
||||
const [first, ...rest] = useGitLog.getState().commits;
|
||||
useGitLog.setState({ commits: [{ ...first, summary, refs: [branch, `tag: ${tag}`] }, ...rest] });
|
||||
},
|
||||
|
||||
@@ -112,57 +112,6 @@ test("Git Log separates commit message typography from compact metadata", async
|
||||
await expect(author).toHaveCSS("font-size", "12px");
|
||||
});
|
||||
|
||||
test("compact Git Log refs give the subject room on either side", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 630, height: 720 });
|
||||
const refSubject = "Reconcile shipping credits";
|
||||
const longReference = "release-quarterly-settlement-and-backoffice-invoice-reconciliation";
|
||||
await page.evaluate(
|
||||
async ({ refSubject, longReference }) => {
|
||||
const optionsModule = "/src/features/vcs/logOptions.ts";
|
||||
const logModule = "/src/features/vcs/logStore.ts";
|
||||
const { setLogOptions } = await import(/* @vite-ignore */ optionsModule);
|
||||
const { useGitLog } = await import(/* @vite-ignore */ logModule);
|
||||
setLogOptions({ showBranches: false, showDetails: false });
|
||||
const [first, ...rest] = useGitLog.getState().commits;
|
||||
useGitLog.setState({
|
||||
commits: [{ ...first, summary: refSubject, message: refSubject, refs: [longReference] }, ...rest],
|
||||
});
|
||||
},
|
||||
{ refSubject, longReference },
|
||||
);
|
||||
const row = page.getByRole("listbox", { name: "Commits" }).getByRole("option").filter({ hasText: refSubject });
|
||||
const subject = row.getByText(refSubject, { exact: true });
|
||||
const ref = row.getByTitle(longReference, { exact: true });
|
||||
const expectLayout = async () => {
|
||||
await expect
|
||||
.poll(() =>
|
||||
subject.evaluate((el) => {
|
||||
const text = document.createRange();
|
||||
text.selectNodeContents(el);
|
||||
return el.getBoundingClientRect().width + 0.02 >= text.getBoundingClientRect().width;
|
||||
}),
|
||||
)
|
||||
.toBe(true);
|
||||
await expect
|
||||
.poll(() =>
|
||||
ref.evaluate((el) => {
|
||||
const refs = el.parentElement!;
|
||||
return refs.clientWidth / refs.parentElement!.clientWidth;
|
||||
}),
|
||||
)
|
||||
.toBeLessThanOrEqual(0.34);
|
||||
await expect(ref).toHaveCSS("font-size", "12px");
|
||||
await expect(subject).toHaveCSS("font-size", "13px");
|
||||
};
|
||||
await expectLayout();
|
||||
await expect.poll(async () => (await subject.boundingBox())!.x < (await ref.boundingBox())!.x).toBe(true);
|
||||
|
||||
await page.getByRole("toolbar", { name: "Log filters" }).getByRole("button", { name: "View Options" }).click();
|
||||
await page.getByRole("menuitemcheckbox", { name: "References on the Left" }).click();
|
||||
await expectLayout();
|
||||
await expect.poll(async () => (await subject.boundingBox())!.x > (await ref.boundingBox())!.x).toBe(true);
|
||||
});
|
||||
|
||||
test("a second click on a Git Log toolbar button closes its popup", async ({ workbench: page }) => {
|
||||
const toolbar = page.getByRole("toolbar", { name: "Log filters" });
|
||||
const branchPopup = page.getByRole("dialog", { name: "Filter by Branch" });
|
||||
@@ -225,50 +174,6 @@ test("Git Log keeps filters and actions inside the commit pane at the minimum wi
|
||||
await expect(page.getByRole("menuitem", { name: "Paths" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("long Git Log filter values shorten inside their buttons", async ({ workbench: page }) => {
|
||||
const branchName = "feature/quarterly-settlement-and-backoffice-invoice-reconciliation";
|
||||
await page.setViewportSize({ width: 1120, height: 720 });
|
||||
await page.evaluate(async (branch) => {
|
||||
const logModule = "/src/features/vcs/logStore.ts";
|
||||
const optionsModule = "/src/features/vcs/logOptions.ts";
|
||||
const { setLogBranches } = await import(/* @vite-ignore */ logModule);
|
||||
const { setLogOptions } = await import(/* @vite-ignore */ optionsModule);
|
||||
setLogOptions({ showBranches: false, showDetails: false });
|
||||
setLogBranches([branch]);
|
||||
}, branchName);
|
||||
|
||||
const toolbar = page.getByRole("toolbar", { name: "Log filters" });
|
||||
const branch = toolbar.getByRole("button", { name: `Branch: ${branchName}`, exact: true });
|
||||
const value = branch.getByText(branchName, { exact: true });
|
||||
const clear = toolbar.getByRole("button", { name: "Clear Branch filter", exact: true });
|
||||
for (const width of [1120, 620]) {
|
||||
await page.setViewportSize({ width, height: 720 });
|
||||
await expect(branch).toBeVisible();
|
||||
await expect(value).toHaveCSS("text-overflow", "ellipsis");
|
||||
expect(
|
||||
await value.evaluate((label) => {
|
||||
const bounds = label.getBoundingClientRect();
|
||||
const button = label.closest("button")!.getBoundingClientRect();
|
||||
return label.scrollWidth > label.clientWidth && bounds.width > 0 && bounds.right <= button.right;
|
||||
}),
|
||||
).toBe(true);
|
||||
await expect(branch).toHaveAttribute("title", branchName);
|
||||
await clear.click({ trial: true });
|
||||
}
|
||||
|
||||
await page.setViewportSize({ width: 400, height: 560 });
|
||||
// The overflow is measured after the resize: open the menu once the filter has moved into it.
|
||||
await expect(branch).toBeHidden();
|
||||
await toolbar.getByRole("button", { name: "More Filters" }).click();
|
||||
await expect(page.getByRole("menuitem", { name: `Branch: ${branchName}`, exact: true })).toBeVisible();
|
||||
await page.keyboard.press("Escape");
|
||||
|
||||
await page.setViewportSize({ width: 620, height: 720 });
|
||||
await clear.click();
|
||||
await expect(toolbar.getByRole("button", { name: "Branch", exact: true })).toBeVisible();
|
||||
await expect(clear).toBeHidden();
|
||||
});
|
||||
|
||||
test("Git Log puts affected changes on the changed-files toolbar and groups preview options", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/** The npm tool window lists package.json scripts without run configurations and runs them. */
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, ipcCalls, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const PKG = JSON.stringify({ name: "acme-api", scripts: { dev: "vite", build: "vite build" } });
|
||||
|
||||
/** The root package.json has scripts; there are no run configurations. */
|
||||
async function stubNpm(page: Page) {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async (pkg) => {
|
||||
const h = window.__ipc.handlers;
|
||||
h.fs_read_text = (args) => (String(args.path).endsWith("/package.json") ? pkg : "");
|
||||
h.run_configs = () => [];
|
||||
h.run_start = (args) => {
|
||||
const config = args.config as { id: string; name: string };
|
||||
return { id: 8, configId: config.id, name: config.name, pid: 4242, running: true, pty: false };
|
||||
};
|
||||
const npmModule = "/src/features/run/npmScripts.ts";
|
||||
const { loadNpmScripts } = await import(/* @vite-ignore */ npmModule);
|
||||
await loadNpmScripts();
|
||||
}, PKG);
|
||||
}
|
||||
|
||||
test("lists scripts without run configurations and runs one on double-click", async ({ workbench: page }) => {
|
||||
await stubNpm(page);
|
||||
await page.getByRole("button", { name: "npm", exact: true }).click();
|
||||
const tree = page.getByRole("tree", { name: "npm scripts" });
|
||||
await expect(tree).toBeVisible();
|
||||
await expect(tree.getByRole("treeitem", { name: /^acme-api/ })).toBeVisible();
|
||||
await expect(tree.getByRole("treeitem", { name: "dev" })).toBeVisible();
|
||||
await expect(tree.getByRole("treeitem", { name: "build" })).toBeVisible();
|
||||
await tree.getByRole("treeitem", { name: "dev" }).dblclick();
|
||||
const [started] = await ipcCalls(page, "run_start");
|
||||
expect(started).toMatchObject({ config: { args: ["run", "dev"], kind: "npm" } });
|
||||
});
|
||||
|
||||
test("offers Run / Debug in a script's context menu", async ({ workbench: page }) => {
|
||||
await stubNpm(page);
|
||||
await page.getByRole("button", { name: "npm", exact: true }).click();
|
||||
const tree = page.getByRole("tree", { name: "npm scripts" });
|
||||
await tree.getByRole("treeitem", { name: "build" }).click({ button: "right" });
|
||||
await expect(page.getByRole("menuitem", { name: /Run '.*run build'/ })).toBeVisible();
|
||||
await expect(page.getByRole("menuitem", { name: /Debug '.*run build'/ })).toBeVisible();
|
||||
});
|
||||
@@ -176,29 +176,7 @@ test("Push keeps commit subjects and changed files readable in a narrow window",
|
||||
await expect(input).toHaveValue("main");
|
||||
await expect(dialog.getByRole("button", { name: "Push", exact: true })).toBeInViewport();
|
||||
const details = dialog.getByRole("region", { name: "Commit details" });
|
||||
await page.evaluate(async () => {
|
||||
const project = "/src/platform/project.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ project);
|
||||
const { settings } = useProject.getState();
|
||||
useProject.setState({
|
||||
settings: {
|
||||
...settings,
|
||||
editor: { ...settings?.editor, fontFamily: "Consolas", fontSize: 18, fontWeight: 400, boldFontWeight: 700 },
|
||||
},
|
||||
});
|
||||
});
|
||||
const messageSubject = details.getByText(OUTGOING, { exact: true });
|
||||
const messageBody = details.getByText("Keep the new totals consistent with receipts.", { exact: true });
|
||||
await expect(messageSubject).toHaveCSS("font-weight", "700");
|
||||
await expect(messageBody).toHaveCSS("font-weight", "400");
|
||||
await expect(messageSubject).toHaveCSS("font-size", "18px");
|
||||
await expect(messageBody).toHaveCSS("font-size", "18px");
|
||||
await expect(messageBody).toHaveCSS("font-family", /Consolas/);
|
||||
const metadata = details.getByText(/Sam Rivera <sam@example\.com>/);
|
||||
await expect(metadata).toHaveCSS("font-size", "12px");
|
||||
await metadata.scrollIntoViewIfNeeded();
|
||||
await expect(metadata).toBeInViewport();
|
||||
expect(await details.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await expect(details).toContainText("Keep the new totals consistent with receipts.");
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const [tree, message] = await Promise.all([files.boundingBox(), details.boundingBox()]);
|
||||
|
||||
@@ -93,42 +93,3 @@ test("Recent Locations keeps all snippet lines visible when the editor font grow
|
||||
await expect(row.getByText("changed", { exact: true })).toBeInViewport({ ratio: 1 });
|
||||
await expect(filter).toBeFocused();
|
||||
});
|
||||
|
||||
test("Recent Locations shows each file name once with its parent directory", async ({ workbench: page }) => {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
const tracking = "/src/features/search/common/tracking.ts";
|
||||
const { useTracking } = await import(/* @vite-ignore */ tracking);
|
||||
const now = Date.now();
|
||||
useTracking.setState({
|
||||
locations: [
|
||||
["README.md", "# Shop API"],
|
||||
["packages/billing/Routes.ts", "registerBillingRoutes();"],
|
||||
["packages/checkout/Routes.ts", "registerCheckoutRoutes();"],
|
||||
].map(([path, snippet], index) => ({
|
||||
path: `/dev/acme-api/${path}`,
|
||||
line: 0,
|
||||
col: 0,
|
||||
changed: false,
|
||||
time: now - index * 60000,
|
||||
snippet: [snippet],
|
||||
snippetStart: 0,
|
||||
})),
|
||||
});
|
||||
});
|
||||
await openRecent(page, "recentLocations");
|
||||
const dialog = page.getByRole("dialog", { name: "Recent Locations", exact: true });
|
||||
const rows = dialog.getByRole("option");
|
||||
await expect(rows).toHaveCount(3);
|
||||
await expect(rows.filter({ hasText: "# Shop API" }).getByText("README.md", { exact: true })).toHaveCount(1);
|
||||
|
||||
const billing = rows.filter({ hasText: "registerBillingRoutes();" });
|
||||
const checkout = rows.filter({ hasText: "registerCheckoutRoutes();" });
|
||||
await expect(billing.getByText("packages/billing", { exact: true })).toBeVisible();
|
||||
await expect(checkout.getByText("packages/checkout", { exact: true })).toBeVisible();
|
||||
await expect(checkout.getByTitle("packages/checkout/Routes.ts", { exact: true })).toBeVisible();
|
||||
|
||||
await dialog.getByRole("textbox", { name: "Filter recent locations" }).fill("packages/checkout");
|
||||
await expect(rows).toHaveCount(1);
|
||||
await expect(rows.first()).toContainText("registerCheckoutRoutes();");
|
||||
});
|
||||
@@ -1,63 +0,0 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("the workspace refactoring preview separates filenames from directories and keeps outcomes readable", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 420, height: 620 });
|
||||
await page.evaluate(async () => {
|
||||
const popupPath = "/src/editor/lsp/popupStore.ts";
|
||||
const editPath = "/src/editor/lsp/workspaceEdit.ts";
|
||||
const { openPopup } = await import(/* @vite-ignore */ popupPath);
|
||||
const { summarizeWorkspaceEdit } = await import(/* @vite-ignore */ editPath);
|
||||
const root = "/dev/acme-api";
|
||||
const edit = {
|
||||
range: { start: { line: 0, col: 0 }, end: { line: 0, col: 9 } },
|
||||
new_text: "postInvoice",
|
||||
};
|
||||
openPopup({
|
||||
kind: "preview",
|
||||
title: "Rename 'saveOrder' to 'postInvoice'",
|
||||
summary: summarizeWorkspaceEdit({
|
||||
files: [
|
||||
{ kind: "edit", path: `${root}/README.md`, edits: [edit] },
|
||||
{ kind: "edit", path: `${root}/packages/billing/src/Routes.ts`, edits: [edit, edit] },
|
||||
{ kind: "edit", path: `${root}/packages/checkout/src/Routes.ts`, edits: [edit] },
|
||||
{
|
||||
kind: "rename",
|
||||
from: `${root}/packages/checkout/src/Invoice.ts`,
|
||||
to: `${root}/packages/checkout/src/InvoiceReconciliationForInternationalOrders.ts`,
|
||||
},
|
||||
],
|
||||
}),
|
||||
renameThemeClasses: "",
|
||||
confirmLabel: "Do Refactor",
|
||||
onConfirm: () => {
|
||||
document.body.dataset.refactorConfirmed = "true";
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
const dialog = page.getByRole("dialog", { name: "Rename 'saveOrder' to 'postInvoice'" });
|
||||
const rows = dialog.getByRole("list", { name: "Changes" }).getByRole("listitem");
|
||||
await expect(rows).toHaveCount(4);
|
||||
await expect(dialog.getByText("4 occurrences in 4 files")).toBeVisible();
|
||||
const root = rows.filter({ hasText: "README.md" });
|
||||
await expect(root.getByText("README.md", { exact: true })).toHaveCount(1);
|
||||
|
||||
const billing = rows.filter({ hasText: "2 occurrences" });
|
||||
await expect(billing.getByText("Routes.ts", { exact: true })).toBeVisible();
|
||||
await expect(billing.getByText("packages/billing/src", { exact: true })).toBeVisible();
|
||||
await expect(billing.getByTitle("packages/billing/src/Routes.ts", { exact: true })).toBeVisible();
|
||||
const checkout = rows.filter({ hasText: "packages/checkout/src" }).filter({ hasText: "Routes.ts" });
|
||||
await expect(checkout.getByText("packages/checkout/src", { exact: true })).toBeVisible();
|
||||
|
||||
const rename = rows.filter({ hasText: "Invoice.ts" });
|
||||
const target = rename.getByText("→ InvoiceReconciliationForInternationalOrders.ts", { exact: true });
|
||||
await expect(target).toBeVisible();
|
||||
await expect(target).toHaveAttribute("title", "packages/checkout/src/InvoiceReconciliationForInternationalOrders.ts");
|
||||
expect((await target.boundingBox())!.width).toBeGreaterThan(35);
|
||||
await expect(dialog.getByRole("button", { name: "Do Refactor", exact: true })).toBeInViewport();
|
||||
await dialog.getByRole("button", { name: "Do Refactor", exact: true }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
await expect(page.locator("body")).toHaveAttribute("data-refactor-confirmed", "true");
|
||||
});
|
||||
@@ -76,73 +76,6 @@ test("⌃R runs the selected configuration and shows its output and exit", async
|
||||
expect(started).toMatchObject({ config: { id: "npm:dev", command: "npm", args: ["run", "dev"] } });
|
||||
});
|
||||
|
||||
test("expanded console folds stay reachable at the start of their rows", async ({ workbench: page }) => {
|
||||
const heading = "Reconciling orders for the overnight settlement and inventory reporting pipeline";
|
||||
await stubRun(
|
||||
page,
|
||||
[
|
||||
{
|
||||
kind: "stdout",
|
||||
text: [
|
||||
"TRACE Reused inventory connection",
|
||||
"TRACE Loaded warehouse configuration",
|
||||
heading,
|
||||
"TRACE Checked warehouse audit result",
|
||||
"TRACE Updated inventory snapshot",
|
||||
"Processed 24 orders",
|
||||
"",
|
||||
].join("\n"),
|
||||
},
|
||||
],
|
||||
null,
|
||||
);
|
||||
await page.evaluate(async () => {
|
||||
const projectModule = "/src/platform/project.ts";
|
||||
const layoutModule = "/src/workbench/toolwindows/store.ts";
|
||||
const { useProject } = await import(/* @vite-ignore */ projectModule);
|
||||
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
|
||||
const { settings } = useProject.getState();
|
||||
useProject.setState({
|
||||
settings: { ...settings, console: { ...settings?.console, foldPatterns: ["TRACE "] } },
|
||||
});
|
||||
moveToolWindow("run", "right");
|
||||
setToolWindowSize("right", 320);
|
||||
});
|
||||
await page.keyboard.press("Control+r");
|
||||
const log = page.getByRole("region", { name: "Run", exact: true }).getByRole("log");
|
||||
const expand = log.getByTitle("Expand folded lines", { exact: true });
|
||||
const collapse = log.getByRole("button", { name: "Collapse folded lines", exact: true });
|
||||
await expect(expand).toHaveCount(2);
|
||||
|
||||
await expand.first().click();
|
||||
await expect(log.getByText("TRACE Reused inventory connection", { exact: true })).toBeVisible();
|
||||
await expect(collapse).toHaveCount(1);
|
||||
await collapse.press("Space");
|
||||
await expect(expand).toHaveCount(2);
|
||||
|
||||
await expand.first().press("Enter");
|
||||
await expect(collapse).toBeFocused();
|
||||
await expand.last().click();
|
||||
await expect(collapse).toHaveCount(2);
|
||||
for (const scrollLeft of [0, 120]) {
|
||||
await log.evaluate((element, x) => (element.scrollLeft = x), scrollLeft);
|
||||
expect(await log.evaluate((element) => element.scrollLeft)).toBe(scrollLeft);
|
||||
for (const control of await collapse.all()) {
|
||||
const aligned = await control.evaluate((button) => {
|
||||
const log = button.closest('[role="log"]')!.getBoundingClientRect();
|
||||
const row = button.closest("[data-index]")!.getBoundingClientRect();
|
||||
const box = button.getBoundingClientRect();
|
||||
return Math.abs(box.left - log.left) <= 1 && box.top >= row.top && box.bottom <= row.bottom + 1;
|
||||
});
|
||||
expect(aligned).toBe(true);
|
||||
}
|
||||
}
|
||||
await collapse.first().click();
|
||||
await collapse.first().click();
|
||||
await expect(expand).toHaveCount(2);
|
||||
expect(await ipcCalls(page, "run_stdin")).toEqual([]);
|
||||
});
|
||||
|
||||
test("⌘F2 stops a running process", async ({ workbench: page }) => {
|
||||
await stubRun(page, [{ kind: "stdout", text: "Watching for changes…\n" }], null);
|
||||
await page.keyboard.press("Control+r");
|
||||
@@ -189,45 +122,6 @@ test("a long Run tab fits its side panel with room for the pin and close buttons
|
||||
await expect(run).toBeHidden();
|
||||
});
|
||||
|
||||
test("the Run toolbar keeps primary actions in one row in a side dock", async ({ workbench: page }) => {
|
||||
const output = "Waiting for orders. ".repeat(8).trim();
|
||||
await stubRun(page, [{ kind: "stdout", text: `${output}\n` }], null);
|
||||
const dock = async (width: number) => {
|
||||
await page.evaluate(async (width) => {
|
||||
const path = "/src/workbench/toolwindows/store.ts";
|
||||
const { moveToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ path);
|
||||
moveToolWindow("run", "right");
|
||||
setToolWindowSize("right", width);
|
||||
}, width);
|
||||
};
|
||||
await dock(200);
|
||||
await page.keyboard.press("Control+r");
|
||||
const run = page.getByRole("region", { name: "Run", exact: true });
|
||||
const toolbar = run.getByRole("toolbar", { name: "Run actions" });
|
||||
const console = run.getByRole("log");
|
||||
await expect(console).toContainText(output);
|
||||
await expect
|
||||
.poll(() => toolbar.evaluate((el) => new Set([...el.querySelectorAll("button")].map((b) => b.offsetTop)).size))
|
||||
.toBe(1);
|
||||
const more = toolbar.getByRole("button", { name: "More Actions" });
|
||||
const menu = page.getByRole("menu", { name: "More Actions" });
|
||||
await more.press("Enter");
|
||||
const wrap = menu.getByRole("menuitemcheckbox", { name: "Soft-Wrap" });
|
||||
await expect(wrap).toHaveAttribute("aria-checked", "false");
|
||||
await expect(menu.getByRole("menuitemcheckbox", { name: "Scroll to End" })).toHaveAttribute("aria-checked", "true");
|
||||
await wrap.click();
|
||||
await expect(menu).toBeHidden();
|
||||
await expect.poll(() => console.evaluate((el) => el.scrollWidth <= el.clientWidth + 1)).toBe(true);
|
||||
|
||||
await dock(340);
|
||||
await expect(toolbar.getByRole("button", { name: "Soft-Wrap" })).toHaveAttribute("aria-pressed", "true");
|
||||
await expect(toolbar.getByRole("button", { name: "Scroll to End" })).toBeVisible();
|
||||
await more.click();
|
||||
await expect(menu.getByRole("menuitemcheckbox")).toHaveCount(0);
|
||||
await menu.getByRole("menuitem", { name: "Edit Configurations…" }).click();
|
||||
await expect(page.getByRole("dialog", { name: "Run/Debug Configurations" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("a short Run pane has room for the full toolbar above the output", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 400, height: 500 });
|
||||
const output = "Watching for changes…";
|
||||
@@ -390,64 +284,6 @@ test("test results keep counts, actions and selected output visible as the pane
|
||||
await expect(output).toContainText(message);
|
||||
});
|
||||
|
||||
test("test results keep elapsed time beside the counts", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1060, height: 740 });
|
||||
const lines = [
|
||||
"test_tax (test_ledger.CheckoutTests.test_tax) ... ok",
|
||||
"test_refund (test_ledger.CheckoutTests.test_refund) ... FAIL",
|
||||
"test_callback (test_ledger.CheckoutTests.test_callback) ... skipped 'Requires a callback'",
|
||||
"Ran 3 tests in 0.170s",
|
||||
"FAILED (failures=1, skipped=1)",
|
||||
];
|
||||
await stubRun(page, [{ kind: "stderr", text: lines.join("\n") + "\n" }], 1, {
|
||||
id: "django:checkout-tests",
|
||||
name: "Checkout tests",
|
||||
kind: "django-test",
|
||||
command: "python",
|
||||
args: ["manage.py", "test", "-v", "2"],
|
||||
isTest: true,
|
||||
});
|
||||
await page.keyboard.press("Control+r");
|
||||
const run = page.getByRole("region", { name: "Run", exact: true });
|
||||
const summary = run.getByRole("status").filter({ hasText: "1 failing" });
|
||||
const ignored = summary.getByText("1 ignored", { exact: true });
|
||||
const elapsed = summary.getByText("170 ms", { exact: true });
|
||||
await expect(elapsed).toBeVisible();
|
||||
for (const width of [1060, 540]) {
|
||||
await page.setViewportSize({ width, height: 740 });
|
||||
await expect
|
||||
.poll(async () => {
|
||||
const [count, duration] = await Promise.all([ignored.boundingBox(), elapsed.boundingBox()]);
|
||||
return count && duration && Math.abs(count.y - duration.y) <= 1 ? duration.x - count.x - count.width : Infinity;
|
||||
})
|
||||
.toBeLessThanOrEqual(12);
|
||||
}
|
||||
await expect(summary).toHaveCSS("border-bottom-width", "2px");
|
||||
});
|
||||
|
||||
test("test results retain a running label after the first test starts", async ({ workbench: page }) => {
|
||||
const name = "TestCheckoutTotals";
|
||||
await stubRun(
|
||||
page,
|
||||
[{ kind: "stdout", text: JSON.stringify({ Package: "example.com/checkout", Action: "run", Test: name }) + "\n" }],
|
||||
null,
|
||||
{
|
||||
id: "go:checkout-tests",
|
||||
name: "Checkout tests",
|
||||
kind: "go",
|
||||
command: "go",
|
||||
args: ["test", "-json"],
|
||||
isTest: true,
|
||||
},
|
||||
);
|
||||
await page.keyboard.press("Control+r");
|
||||
const run = page.getByRole("region", { name: "Run", exact: true });
|
||||
await expect(run.getByRole("treeitem", { name: new RegExp(name) })).toBeVisible();
|
||||
const summary = run.getByRole("status").filter({ hasText: "Running…" });
|
||||
await expect(summary).toBeVisible();
|
||||
await expect(summary).toHaveCSS("border-bottom-width", "2px");
|
||||
});
|
||||
|
||||
test("test results group failure navigation and let users hide row durations", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 540, height: 740 });
|
||||
const first = "TestCheckoutTotalsWithTaxRoundingAndPendingRefunds";
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { Locator, Page } from "@playwright/test";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
for (const height of [990, 700, 560]) {
|
||||
test(`run configurations dialog keeps its toolbar and name visible while scrolling at ${height}px`, async ({
|
||||
test(`run configurations dialog keeps its toolbar and scrolls only inside the panes at ${height}px`, async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.setViewportSize({ width: 900, height });
|
||||
@@ -62,13 +62,9 @@ async function resize(page: Page, dialog: Locator, dy: number) {
|
||||
async function checkScrolling(page: Page, dialog: Locator) {
|
||||
const body = dialog.locator("[data-dialog-body]");
|
||||
const list = dialog.getByRole("tree", { name: "Run configurations", exact: true });
|
||||
const form = dialog.locator('[class*="_formSettings_"]');
|
||||
const nameField = dialog.getByRole("textbox", { name: "Name", exact: true });
|
||||
const form = dialog.locator('[class*="_editForm_"]');
|
||||
await list.evaluate((el) => (el.scrollTop = 0));
|
||||
await form.evaluate((el) => (el.scrollTop = 0));
|
||||
// Measure once the dialog's opening animation has settled.
|
||||
await dialog.evaluate((el) => Promise.all(el.getAnimations().map((animation) => animation.finished)));
|
||||
const nameTop = (await nameField.boundingBox())!.y;
|
||||
await list.hover();
|
||||
await page.mouse.wheel(0, 200);
|
||||
await expect.poll(() => list.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
|
||||
@@ -78,8 +74,6 @@ async function checkScrolling(page: Page, dialog: Locator) {
|
||||
await page.mouse.wheel(0, 200);
|
||||
await expect.poll(() => form.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
|
||||
expect(await list.evaluate((el) => el.scrollTop)).toBe(listTop);
|
||||
expect((await nameField.boundingBox())!.y).toBeCloseTo(nameTop, 0);
|
||||
await expect(dialog.getByRole("checkbox", { name: /Store as project file/ })).toBeInViewport({ ratio: 1 });
|
||||
const overflow = await body.evaluate((el) => ({
|
||||
scroll: el.scrollHeight,
|
||||
client: el.clientHeight,
|
||||
|
||||
@@ -112,7 +112,7 @@ test("resizing the configuration dialog grows its panes and keeps the footer vis
|
||||
await expect(dialog.getByRole("tree", { name: "Run configurations", exact: true })).toBeVisible();
|
||||
await expect.poll(async () => (await content.boundingBox())!.height).toBeLessThan(initial);
|
||||
await expect
|
||||
.poll(() => dialog.locator("[class*='_formSettings_']").evaluate((el) => el.scrollHeight - el.clientHeight))
|
||||
.poll(() => dialog.locator("[class*='editForm_']").evaluate((el) => el.scrollHeight - el.clientHeight))
|
||||
.toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
@@ -144,7 +144,7 @@ test("Java, npm and Python forms fit narrow and zoomed content panes", async ({
|
||||
for (const width of [1024, 640, 520]) {
|
||||
await page.setViewportSize({ width, height: 820 });
|
||||
await expect
|
||||
.poll(() => dialog.locator("[class*='_formSettings_']").evaluate((el) => el.scrollWidth - el.clientWidth), {
|
||||
.poll(() => dialog.locator("[class*='editForm_']").evaluate((el) => el.scrollWidth - el.clientWidth), {
|
||||
message: `${kind}, ${width}px, ${zoom * 100}%`,
|
||||
})
|
||||
.toBeLessThanOrEqual(1);
|
||||
@@ -204,7 +204,7 @@ for (const locale of ["en", "zh"]) {
|
||||
)
|
||||
.toMatchObject({ overflow: expect.any(Number), footerFits: true, footerVisible: true });
|
||||
await expect
|
||||
.poll(() => dialog.locator("[class*='_formSettings_']").evaluate((el) => el.scrollWidth - el.clientWidth))
|
||||
.poll(() => dialog.locator("[class*='editForm_']").evaluate((el) => el.scrollWidth - el.clientWidth))
|
||||
.toBeLessThanOrEqual(1);
|
||||
const tasks = dialog.getByRole("list");
|
||||
await tasks.scrollIntoViewIfNeeded();
|
||||
|
||||
@@ -1,60 +1,6 @@
|
||||
import { doubleShift, expect, stubDesktop, test } from "./fixtures";
|
||||
import type { Page } from "@playwright/test";
|
||||
|
||||
test("action names stay readable beside shortcuts and categories", async ({ workbench: page }) => {
|
||||
const titles = ["Reconcile warehouse totals", "Reconcile settlement exports"];
|
||||
const shortcuts = await page.evaluate(async (titles) => {
|
||||
const actionsModule = "/src/platform/actions.ts";
|
||||
const keymapModule = "/src/platform/keymap.ts";
|
||||
const { registerActions, executeAction } = await import(/* @vite-ignore */ actionsModule);
|
||||
const platformModule = "/src/platform/platformInfo.ts";
|
||||
const { registerExtensionBindings, shortcutLabel } = await import(/* @vite-ignore */ keymapModule);
|
||||
const { usePlatform } = await import(/* @vite-ignore */ platformModule);
|
||||
usePlatform.setState({ os: "windows" });
|
||||
const ids = ["review.reconcileWarehouse", "review.reconcileSettlement"];
|
||||
const bindings = ["Ctrl+K Ctrl+R", "Ctrl+Alt+Shift+PageDown Ctrl+Alt+Shift+PageUp"];
|
||||
registerActions(
|
||||
titles.map((title, index) => ({
|
||||
id: ids[index]!,
|
||||
title,
|
||||
category: "Warehouse reconciliation and settlement reports",
|
||||
icon: "check",
|
||||
run: () => document.body.setAttribute("data-review-action", title),
|
||||
})),
|
||||
);
|
||||
ids.forEach((id, index) => registerExtensionBindings(id, [bindings[index]!]));
|
||||
await executeAction("navigate.findAction");
|
||||
return ids.map((id) => shortcutLabel(id) as string);
|
||||
}, titles);
|
||||
const dialog = page.locator('[role="dialog"]:has(#se-query)');
|
||||
await dialog.getByRole("combobox", { name: "Search query" }).fill("Reconcile");
|
||||
|
||||
for (const width of [400, 1120]) {
|
||||
await page.setViewportSize({ width, height: 630 });
|
||||
for (const [index, title] of titles.entries()) {
|
||||
const row = dialog.getByRole("option").filter({ hasText: title });
|
||||
const keys = row.getByText(shortcuts[index]!, { exact: true });
|
||||
await expect(keys).toBeAttached();
|
||||
const geometry = await keys.evaluate((el) => {
|
||||
const name = el.previousElementSibling!.getBoundingClientRect();
|
||||
const main = el.parentElement!.getBoundingClientRect();
|
||||
const key = el.getBoundingClientRect();
|
||||
return { name: name.width, inside: key.left >= name.right && key.right <= main.right + 1 };
|
||||
});
|
||||
expect(geometry.name).toBeGreaterThanOrEqual(80);
|
||||
expect(geometry.inside).toBe(true);
|
||||
await expect(keys).toHaveCSS("font-size", "12px");
|
||||
await expect(keys).toHaveCSS("font-weight", "600");
|
||||
await expect(keys).toHaveAttribute("title", shortcuts[index]!);
|
||||
if (index === 0) expect(await keys.evaluate((el) => el.scrollWidth <= el.clientWidth)).toBe(true);
|
||||
}
|
||||
}
|
||||
|
||||
await dialog.getByRole("option").filter({ hasText: titles[1]! }).click();
|
||||
await expect(dialog).toBeHidden();
|
||||
await expect(page.locator("body")).toHaveAttribute("data-review-action", titles[1]!);
|
||||
});
|
||||
|
||||
async function searchFiles(page: Page) {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(() => {
|
||||
|
||||
@@ -3,9 +3,7 @@
|
||||
* header on screen: titles stay on one line and every header control lies inside the popup.
|
||||
*/
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, openFromTree, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const LONG_RESULT_PATH = "config/RegionalOrderReconciliationEndpointsForSandboxEnvironments.txt";
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
async function run(page: Page, id: string) {
|
||||
await page.evaluate(async (id) => {
|
||||
@@ -17,16 +15,15 @@ async function run(page: Page, id: string) {
|
||||
|
||||
async function stubFindMatches(page: Page) {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate((longPath) => {
|
||||
await page.evaluate(() => {
|
||||
window.__ipc.handlers.search_validate = () => null;
|
||||
window.__ipc.handlers.search_start = (args) => {
|
||||
const send = (event: unknown) => window.__ipc.send(args.onEvent, event);
|
||||
const text = "base=http://localhost:8080";
|
||||
setTimeout(() => {
|
||||
for (let i = 0; i < 12; i++) {
|
||||
const relPath = i === 0 ? longPath : `config/endpoint-${i}.txt`;
|
||||
const lines = i === 0 ? [12344, 12345] : [0];
|
||||
const matches = lines.map((line) => ({ line, text, ranges: [[5, text.length]], textOffset: 0 }));
|
||||
const relPath = `config/endpoint-${i}.txt`;
|
||||
const matches = [{ line: 0, text, ranges: [[5, text.length]], textOffset: 0 }];
|
||||
send({
|
||||
type: "file",
|
||||
file: { path: `/dev/acme-api/${relPath}`, relPath, matches },
|
||||
@@ -34,12 +31,12 @@ async function stubFindMatches(page: Page) {
|
||||
}
|
||||
send({
|
||||
type: "done",
|
||||
summary: { files: 12, matches: 13, limitHit: false, cancelled: false, elapsedMs: 4 },
|
||||
summary: { files: 12, matches: 12, limitHit: false, cancelled: false, elapsedMs: 4 },
|
||||
});
|
||||
}, 20);
|
||||
return null;
|
||||
};
|
||||
}, LONG_RESULT_PATH);
|
||||
});
|
||||
}
|
||||
|
||||
async function expectControlsFit(page: Page) {
|
||||
@@ -77,8 +74,7 @@ test.describe("search popups at the minimum window width", () => {
|
||||
await expect(page.getByRole("dialog").locator("header [aria-live]")).toContainText(/match/);
|
||||
const dialog = page.getByRole("dialog");
|
||||
const title = dialog.getByText(id === "find.inPath" ? "Find in Files" : "Replace in Files", { exact: true });
|
||||
const count = dialog.getByText("13 matches in 12 files", { exact: true });
|
||||
const line = dialog.getByText("12345", { exact: true });
|
||||
const count = dialog.getByText("12 matches in 12 files", { exact: true });
|
||||
for (const [width, height] of [
|
||||
[400, 500],
|
||||
[600, 700],
|
||||
@@ -91,14 +87,6 @@ test.describe("search popups at the minimum window width", () => {
|
||||
expect(
|
||||
await text.evaluate((el) => el.getClientRects().length === 1 && el.scrollWidth <= el.clientWidth),
|
||||
).toBe(true);
|
||||
await expect(line).toBeVisible();
|
||||
expect(
|
||||
await line.evaluate(
|
||||
(el) => el.getBoundingClientRect().right <= el.parentElement!.getBoundingClientRect().right + 0.5,
|
||||
),
|
||||
"the line number fits even when the long filename is elided",
|
||||
).toBe(true);
|
||||
await expect(line.locator("..").getByTitle(LONG_RESULT_PATH)).toBeVisible();
|
||||
for (const name of ["Search Context", "Pin Window"])
|
||||
await dialog.getByRole("button", { name, exact: true }).click({ trial: true });
|
||||
}
|
||||
@@ -118,49 +106,6 @@ test.describe("search popups at the minimum window width", () => {
|
||||
await dialog.getByRole("button", { name: /Browse/ }).click({ trial: true });
|
||||
});
|
||||
|
||||
test("Replace in Files keeps its footer actions together as the window narrows", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 1120, height: 750 });
|
||||
await openFromTree(page, "settings.gradle.kts");
|
||||
await stubFindMatches(page);
|
||||
await run(page, "find.replaceInPath");
|
||||
const dialog = page.getByRole("dialog", { name: "Replace in Files" });
|
||||
const search = dialog.getByRole("textbox", { name: "Text to find" });
|
||||
await search.fill("http://localhost:8080");
|
||||
await expect(dialog.locator("header [aria-live]")).toContainText("13 matches in 12 files");
|
||||
await search.press("Shift+ArrowDown");
|
||||
await search.press("Shift+ArrowDown");
|
||||
|
||||
const footer = dialog.locator("footer");
|
||||
const open = footer.getByRole("button", { name: "Open in Find Window", exact: true });
|
||||
const shortcut = footer.getByText(/^(Ctrl\+Enter|⌘↵)$/);
|
||||
const replaceAll = footer.getByRole("button", { name: "Replace All", exact: true });
|
||||
const replaceSelected = footer.getByRole("button", { name: "Replace 3 Occurrences", exact: true });
|
||||
await expect(replaceSelected).toBeEnabled();
|
||||
for (const [width, height] of [
|
||||
[400, 500],
|
||||
[1120, 750],
|
||||
] as const) {
|
||||
await page.setViewportSize({ width, height });
|
||||
const [key, find, all, selected] = await Promise.all([
|
||||
shortcut.boundingBox(),
|
||||
open.boundingBox(),
|
||||
replaceAll.boundingBox(),
|
||||
replaceSelected.boundingBox(),
|
||||
]);
|
||||
if (!key || !find || !all || !selected) throw new Error("Expected all footer actions to be visible");
|
||||
expect(Math.abs(key.y + key.height / 2 - find.y - find.height / 2)).toBeLessThanOrEqual(1);
|
||||
expect(Math.abs(all.y - selected.y)).toBeLessThanOrEqual(1);
|
||||
await expectControlsFit(page);
|
||||
await expect(footer).toBeInViewport({ ratio: 1 });
|
||||
await expect(shortcut).toHaveCSS("font-size", "12px");
|
||||
await open.click({ trial: true });
|
||||
await replaceSelected.click({ trial: true });
|
||||
}
|
||||
await search.press("Meta+Enter");
|
||||
await expect(dialog).toBeHidden();
|
||||
await expect(page.getByRole("region", { name: "Find", exact: true })).toContainText("http://localhost:8080");
|
||||
});
|
||||
|
||||
for (const id of [
|
||||
"navigate.searchEverywhere",
|
||||
"navigate.searchText",
|
||||
|
||||
@@ -1,38 +1,5 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("keeps the current settings page name readable when the path is wider than the pane", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await page.keyboard.press("Meta+,");
|
||||
const settings = page.getByRole("dialog", { name: "Settings", exact: true });
|
||||
const search = settings.getByRole("textbox", { name: "Search settings" });
|
||||
await search.fill("Maven");
|
||||
const path = settings.getByLabel("Breadcrumb", { exact: true });
|
||||
const parent = path.getByText("Build, Execution, Deployment", { exact: true });
|
||||
const current = path.getByText("Maven", { exact: true });
|
||||
await expect(current).toBeVisible();
|
||||
await search.clear();
|
||||
|
||||
for (const width of [400, 560, 1120]) {
|
||||
await page.setViewportSize({ width, height: 720 });
|
||||
await expect
|
||||
.poll(() =>
|
||||
current.evaluate((label) => {
|
||||
const box = label.getBoundingClientRect();
|
||||
const trail = label.closest("[aria-label=Breadcrumb]")!.getBoundingClientRect();
|
||||
return label.clientWidth >= label.scrollWidth && box.width > 0 && box.right <= trail.right + 1;
|
||||
}),
|
||||
)
|
||||
.toBe(true);
|
||||
}
|
||||
await expect(parent).toBeInViewport({ ratio: 1 });
|
||||
expect(await parent.evaluate((label) => label.scrollWidth <= label.clientWidth)).toBe(true);
|
||||
await settings.getByRole("button", { name: "Back", exact: true }).click();
|
||||
await expect(current).toBeHidden();
|
||||
await settings.getByRole("button", { name: "Forward", exact: true }).click();
|
||||
await expect(current).toBeVisible();
|
||||
});
|
||||
|
||||
test("dirty settings keep scope labels and navigation inside the page header", async ({ workbench: page }) => {
|
||||
await page.keyboard.press("Meta+,");
|
||||
await expect(page.getByRole("dialog", { name: "Settings", exact: true })).toBeVisible();
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
test("Show Usages distinguishes same-named files without losing the line or snippet", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 480, height: 620 });
|
||||
await page.evaluate(async () => {
|
||||
const usages = "/src/features/code-insight/usages.ts";
|
||||
const { useUsagesPopup } = await import(/* @vite-ignore */ usages);
|
||||
const symbol = "submitOrder";
|
||||
useUsagesPopup.setState({
|
||||
open: true,
|
||||
anchor: { x: 30, y: 90 },
|
||||
symbol,
|
||||
groups: (
|
||||
[
|
||||
["/dev/acme-api/packages/billing/src/Routes.ts", "return submitOrder(invoice);"],
|
||||
["/dev/acme-api/packages/checkout/src/Routes.ts", "return submitOrder(cart);"],
|
||||
["/dev/acme-api/src/Worker.ts", "await submitOrder(job);"],
|
||||
] as const
|
||||
).map(([path, text]) => {
|
||||
const col = text.indexOf(symbol);
|
||||
return { path, usages: [{ path, line: 6, col, endCol: col + symbol.length, text }] };
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
||||
const popup = page.getByRole("dialog", { name: "Usages", exact: true });
|
||||
const rows = popup.getByRole("option");
|
||||
const billing = rows.filter({ hasText: "invoice" });
|
||||
const checkout = rows.filter({ hasText: "cart" });
|
||||
await expect(rows).toHaveCount(3);
|
||||
for (const [row, directory] of [
|
||||
[billing, "billing"],
|
||||
[checkout, "checkout"],
|
||||
] as const) {
|
||||
await expect(row.getByText("Routes.ts", { exact: true })).toBeVisible();
|
||||
const caption = row.getByText(directory, { exact: true });
|
||||
await expect(caption).toBeVisible();
|
||||
expect(await caption.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
await expect(row.getByText("7", { exact: true })).toBeVisible();
|
||||
await expect(row.locator("mark")).toHaveText("submitOrder");
|
||||
}
|
||||
|
||||
await expect(checkout.getByTitle("/dev/acme-api/packages/checkout/src/Routes.ts", { exact: true })).toBeVisible();
|
||||
await expect(rows.filter({ hasText: "Worker.ts" }).getByText("src", { exact: true })).toHaveCount(0);
|
||||
});
|
||||
@@ -11,7 +11,6 @@ something to show.
|
||||
| `ts-app/` | Node 22+, pnpm/npm | `pnpm start` | `pnpm test` (vitest) | `OPENIDEA_FAIL=1 pnpm test` | unused function in `src/index.ts` |
|
||||
| `playwright-app/` | Node 22+, npm (Playwright Test, no browser needed) | — | `npm test` | `OPENIDEA_FAIL=1 npm test` | unused function in `src/checkout.ts` |
|
||||
| `node-test-app/` | Node 22+, npm (no dependencies) | — | `npm test` (node:test) | `OPENIDEA_FAIL=1 npm test` | unused constant in `src/inventory.js` |
|
||||
| `mocha-app/` | Node 22+, npm | — | `npm test` (Mocha) | `OPENIDEA_FAIL=1 npm test` | unused constant in `src/pricing.js` |
|
||||
| `python-app/` | Python 3.10+, pytest | `python -m tasks.cli` (from `src/`) | `pytest` | `OPENIDEA_FAIL=1 pytest` | unused imports in `models.py` |
|
||||
| `go-app/` | Go 1.22+ | `go run ./cmd/server` | `go test ./...` | `OPENIDEA_FAIL=1 go test ./...` | unused `fmt.Sprintf` result in `internal/store/store.go` |
|
||||
| `kotlin-gradle/` | JDK 21, Gradle 8 (no wrapper) | `gradle run` | `gradle test` | `gradle test -PopenideaFail` | unused variable in `App.kt` |
|
||||
@@ -19,10 +18,7 @@ something to show.
|
||||
| `c-app/` | gcc / g++ 12+, make, GDB 14+ | `make all` | — | — | — |
|
||||
| `php-app/` | PHP 8.5, Composer | `composer quote` | `vendor/bin/pest` | `OPENIDEA_FAIL=1 vendor/bin/pest` | unused variable in `ThresholdCustoms.php` |
|
||||
| `django-app/` | Python 3.10+, Django 5.2+ | `python manage.py runserver` | `python manage.py test` | `OPENIDEA_FAIL=1 python manage.py test` | unused import in `shop/views.py` |
|
||||
| `tailwind-app/` | Node 22+, pnpm/npm, Tailwind CSS 4, React | `pnpm dev` | — | — | `flex` conflicting with `block` in `src/App.tsx` |
|
||||
| `zig-app/` | Zig 0.17 | `zig build run` | `zig build test` | — | — |
|
||||
| `biome-app/` | Node 22+, `@biomejs/biome` (`npm install`) | `npm start` | — | — | `let` never reassigned, `==` and a duplicate CSS `color` (Biome) |
|
||||
| `stylelint-app/` | Node 22+, `stylelint` (`npm install`) | — | — | — | long hex colour, unknown property, empty block, duplicate selector (Stylelint) |
|
||||
| `polyglot/` | Go, TS, Python, C, shell, SQL, TOML/YAML/JSON, proto, Terraform | `make` | `make test` | — | unused variable in `native/hash.c` |
|
||||
|
||||
The fixtures are standalone: `rust-app` declares its own `[workspace]` and
|
||||
@@ -45,7 +41,7 @@ git init -q && git add -A && git commit -qm "initial" # for the VCS checks
|
||||
```
|
||||
|
||||
Then open the folder with **File › Open…** (`⌘⇧⌥O`) or from the Welcome screen.
|
||||
For `ts-app` / `playwright-app` / `mocha-app` / `polyglot/web` run `pnpm install` first (`npm install` for `biome-app` and `stylelint-app`); for `python-app` create a
|
||||
For `ts-app` / `playwright-app` / `polyglot/web` run `pnpm install` first; for `python-app` create a
|
||||
venv (`python3 -m venv .venv && .venv/bin/pip install -e '.[dev]'`); for
|
||||
`php-app` run `composer install` (debugging it needs Xdebug in the PHP on `PATH`).
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"$schema": "https://biomejs.dev/schemas/2.6.8/schema.json",
|
||||
"files": {
|
||||
"includes": ["**", "!node_modules"]
|
||||
},
|
||||
"formatter": {
|
||||
"enabled": true,
|
||||
"indentStyle": "space",
|
||||
"indentWidth": 2,
|
||||
"lineWidth": 100
|
||||
},
|
||||
"javascript": {
|
||||
"formatter": {
|
||||
"quoteStyle": "single"
|
||||
}
|
||||
},
|
||||
"linter": {
|
||||
"enabled": true,
|
||||
"rules": {
|
||||
"preset": "recommended",
|
||||
"style": {
|
||||
"useConst": "error",
|
||||
"useTemplate": "warn"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"name": "openidea-fixture-biome",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "OpenIDEA QA fixture: Biome lint diagnostics, fixes and formatting",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "node --experimental-strip-types src/index.ts",
|
||||
"lint": "biome lint",
|
||||
"format": "biome format --write",
|
||||
"check": "biome check"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "2.6.8"
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
export interface Item {
|
||||
name: string
|
||||
price: number
|
||||
quantity: number
|
||||
}
|
||||
|
||||
export function total(items: Item[]): number {
|
||||
let sum = 0
|
||||
for (const item of items) sum += item.price * item.quantity
|
||||
return sum
|
||||
}
|
||||
|
||||
// Intentional Biome problems: `let` never reassigned (useConst, safe fix),
|
||||
// string concatenation (useTemplate) and `==` (noDoubleEquals).
|
||||
export function describe(items: Item[]): string {
|
||||
let label = "Cart: " + items.length + " items"
|
||||
if (items.length == 0) {
|
||||
return "Cart is empty"
|
||||
}
|
||||
return label
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
{ "currency": "EUR",
|
||||
"discounts": [ 5, 10,15 ] }
|
||||
@@ -1,9 +0,0 @@
|
||||
import { describe, total, type Item } from "./cart.ts"
|
||||
|
||||
const items: Item[] = [
|
||||
{ name: "Notebook", price: 4.5, quantity: 2 },
|
||||
{ name: "Pen", price: 1.25, quantity: 4 },
|
||||
]
|
||||
|
||||
// Set a breakpoint here
|
||||
console.log(describe(items), "-", total(items).toFixed(2))
|
||||
@@ -1,6 +0,0 @@
|
||||
/* Intentional Biome problem: `color` is declared twice (noDuplicateProperties). */
|
||||
.cart {
|
||||
color: #333;
|
||||
padding:4px 8px;
|
||||
color: #444;
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
node_modules
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"name": "openidea-fixture-pricing",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "OpenIDEA QA fixture: Mocha specs for a small pricing module",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^10.8.0"
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
export function withTax(net, rate) {
|
||||
if (rate < 0) throw new RangeError("tax rate must not be negative");
|
||||
return Math.round(net * (1 + rate) * 100) / 100;
|
||||
}
|
||||
|
||||
export function bulkDiscount(quantity) {
|
||||
// TODO: read the tiers from the catalog instead of hard-coding them
|
||||
if (quantity >= 100) return 0.15;
|
||||
if (quantity >= 10) return 0.05;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// An intentional warning: never used.
|
||||
const CURRENCY = "EUR";
|
||||
@@ -1,29 +0,0 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { bulkDiscount, withTax } from "../src/pricing.js";
|
||||
|
||||
describe("pricing", function () {
|
||||
describe("withTax", function () {
|
||||
it("adds the rate", function () {
|
||||
assert.equal(withTax(100, 0.2), 120);
|
||||
});
|
||||
|
||||
it("rejects a negative rate", function () {
|
||||
assert.throws(() => withTax(100, -0.1), RangeError);
|
||||
});
|
||||
});
|
||||
|
||||
describe("bulkDiscount", function () {
|
||||
it("has no discount for a few items", function () {
|
||||
assert.equal(bulkDiscount(3), 0);
|
||||
});
|
||||
|
||||
it("discounts large orders", function () {
|
||||
assert.equal(bulkDiscount(250), 0.15);
|
||||
});
|
||||
});
|
||||
|
||||
it("intentionally fails (set OPENIDEA_FAIL=1)", function () {
|
||||
if (!process.env.OPENIDEA_FAIL) this.skip();
|
||||
assert.equal(withTax(10, 0.1), 11.5);
|
||||
});
|
||||
});
|
||||
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"name": "openidea-fixture-stylelint",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "OpenIDEA QA fixture: Stylelint diagnostics and fixes for CSS, SCSS and Less",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"lint": "stylelint \"src/**/*.{css,scss,less}\"",
|
||||
"fix": "stylelint \"src/**/*.{css,scss,less}\" --fix"
|
||||
},
|
||||
"devDependencies": {
|
||||
"postcss-less": "6.0.0",
|
||||
"stylelint": "18.1.0",
|
||||
"stylelint-config-standard": "41.1.0",
|
||||
"stylelint-config-standard-scss": "18.0.0"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
/* Intentional Stylelint problems: a long hex colour (color-hex-length, fixable)
|
||||
and a misspelt property (property-no-unknown). */
|
||||
.card {
|
||||
color: #ffffff;
|
||||
colour: red;
|
||||
padding: 4px 8px;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
@gutter: 16px;
|
||||
|
||||
// Intentional Stylelint problem: the same selector twice (no-duplicate-selectors).
|
||||
.layout {
|
||||
margin: @gutter;
|
||||
}
|
||||
|
||||
.layout {
|
||||
padding: @gutter;
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
$accent: #336699;
|
||||
|
||||
// Intentional Stylelint problem: an empty block (block-no-empty).
|
||||
.button {
|
||||
color: $accent;
|
||||
|
||||
&:hover {
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
/** @type {import("stylelint").Config} */
|
||||
export default {
|
||||
extends: ["stylelint-config-standard"],
|
||||
overrides: [
|
||||
{ files: ["**/*.scss"], extends: ["stylelint-config-standard-scss"] },
|
||||
{ files: ["**/*.less"], customSyntax: "postcss-less" },
|
||||
],
|
||||
};
|
||||
@@ -1,2 +0,0 @@
|
||||
node_modules
|
||||
dist
|
||||
@@ -1,13 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Tailwind fixture</title>
|
||||
<link rel="stylesheet" href="/src/app.css" />
|
||||
</head>
|
||||
<body class="min-h-screen bg-slate-50 text-slate-900">
|
||||
<div id="root" class="mx-auto max-w-2xl p-8"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"name": "openidea-fixture-tailwind",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"description": "OpenIDEA QA fixture: a Tailwind CSS 4 page with React",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc -p . && vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tailwindcss/vite": "^4.1.0",
|
||||
"@types/react": "^19.0.0",
|
||||
"@types/react-dom": "^19.0.0",
|
||||
"@vitejs/plugin-react": "^5.0.0",
|
||||
"tailwindcss": "^4.1.0",
|
||||
"typescript": "^5.6.0",
|
||||
"vite": "^7.0.0"
|
||||
}
|
||||
}
|
||||
Loaded 100 of 249 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Заблокувати користувача