(
project_root: &Path,
adapter: &LspAdapterDefinition,
file: &str,
)
| 79 | } |
| 80 | |
| 81 | pub fn adapter_workspace_root( |
| 82 | project_root: &Path, |
| 83 | adapter: &LspAdapterDefinition, |
| 84 | file: &str, |
| 85 | ) -> Option<PathBuf> { |
| 86 | if adapter.root_markers.is_empty() { |
| 87 | return Some(project_root.to_path_buf()); |
| 88 | } |
| 89 | let path = project_root.join(file); |
| 90 | let mut current = path.parent(); |
| 91 | while let Some(dir) = current { |
| 92 | if adapter |
| 93 | .root_markers |
| 94 | .iter() |
| 95 | .any(|marker| dir.join(marker).exists()) |
| 96 | { |
| 97 | return Some(dir.to_path_buf()); |
| 98 | } |
| 99 | if dir == project_root { |
| 100 | break; |
| 101 | } |
| 102 | current = dir.parent(); |
| 103 | } |
| 104 | None |
| 105 | } |
| 106 | |
| 107 | #[cfg(test)] |
| 108 | mod tests { |
no test coverage detected