(fileUri, projectRoot)
| 178 | } |
| 179 | |
| 180 | function collectCandidateDirectories(fileUri, projectRoot) { |
| 181 | const directories = []; |
| 182 | const visited = new Set(); |
| 183 | let currentDir = safeDirname(fileUri); |
| 184 | |
| 185 | while (currentDir) { |
| 186 | const normalized = normalizePath(currentDir); |
| 187 | if (visited.has(normalized)) break; |
| 188 | directories.push(currentDir); |
| 189 | visited.add(normalized); |
| 190 | if (projectRoot && pathsAreSame(currentDir, projectRoot)) break; |
| 191 | const parent = safeDirname(currentDir); |
| 192 | if (!parent || parent === currentDir) break; |
| 193 | currentDir = parent; |
| 194 | } |
| 195 | |
| 196 | if ( |
| 197 | projectRoot && |
| 198 | !directories.some((dir) => pathsAreSame(dir, projectRoot)) |
| 199 | ) { |
| 200 | directories.push(projectRoot); |
| 201 | } |
| 202 | |
| 203 | return directories; |
| 204 | } |
| 205 | |
| 206 | function safeDirname(path) { |
| 207 | try { |
no test coverage detected