(uri: vscode.Uri)
| 153 | } |
| 154 | |
| 155 | function moduleNameFromPath(uri: vscode.Uri): string | undefined { |
| 156 | const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri); |
| 157 | if (!workspaceFolder) { |
| 158 | return undefined; |
| 159 | } |
| 160 | let relativePath = path.relative(workspaceFolder.uri.fsPath, uri.fsPath); |
| 161 | if (relativePath.startsWith('..')) { |
| 162 | return undefined; |
| 163 | } |
| 164 | if (relativePath.endsWith('.py')) { |
| 165 | relativePath = relativePath.slice(0, -3); |
| 166 | } else { |
| 167 | return undefined; |
| 168 | } |
| 169 | return relativePath |
| 170 | .split(path.sep) |
| 171 | .filter(part => part.length > 0) |
| 172 | .join('.'); |
| 173 | } |
| 174 | |
| 175 | async function runAtCursor( |
| 176 | uri: vscode.Uri, |
no test coverage detected