Skip to content

Commit

Permalink
Ensure relative paths to interpreters are prefixed with './' in setti…
Browse files Browse the repository at this point in the history
…ngs.json (#2750)

* Prefix relative paths with './'
* Ensure relative path is prefixed with ./
  • Loading branch information
DonJayamanne authored Oct 2, 2018
1 parent 9c04f3b commit 56f1fd1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions news/2 Fixes/2744.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure relative paths to python interpreters in `python.pythonPath` of `settings.json` are prefixed with `./` or `.\\` (depending on the OS).
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class WorkspaceFolderPythonPathUpdaterService implements IPythonPathUpdat
return;
}
if (pythonPath.startsWith(this.workspaceFolder.fsPath)) {
pythonPath = path.relative(this.workspaceFolder.fsPath, pythonPath);
pythonPath = path.join('.', path.relative(this.workspaceFolder.fsPath, pythonPath));
}
await pythonConfig.update('pythonPath', pythonPath, ConfigurationTarget.WorkspaceFolder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class WorkspacePythonPathUpdaterService implements IPythonPathUpdaterServ
return;
}
if (pythonPath.startsWith(this.workspace.fsPath)) {
pythonPath = path.relative(this.workspace.fsPath, pythonPath);
pythonPath = path.join('.', path.relative(this.workspace.fsPath, pythonPath));
}
await pythonConfig.update('pythonPath', pythonPath, false);
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/interpreters/pythonPathUpdater.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ suite('Python Path Settings Updater', () => {
const workspaceFolder = Uri.file(workspaceFolderPath);
const updater = updaterServiceFactory.getWorkspaceFolderPythonPathConfigurationService(workspaceFolder);
const pythonPath = Uri.file(path.join(workspaceFolderPath, 'env', 'bin', 'python')).fsPath;
const expectedPythonPath = path.join('env', 'bin', 'python');
const expectedPythonPath = path.join('.', 'env', 'bin', 'python');
const workspaceConfig = setupConfigProvider(workspaceFolder);
workspaceConfig.setup(w => w.inspect(TypeMoq.It.isValue('pythonPath'))).returns(() => undefined);

Expand Down Expand Up @@ -120,7 +120,7 @@ suite('Python Path Settings Updater', () => {
const workspaceFolder = Uri.file(workspaceFolderPath);
const updater = updaterServiceFactory.getWorkspacePythonPathConfigurationService(workspaceFolder);
const pythonPath = Uri.file(path.join(workspaceFolderPath, 'env', 'bin', 'python')).fsPath;
const expectedPythonPath = path.join('env', 'bin', 'python');
const expectedPythonPath = path.join('.', 'env', 'bin', 'python');
const workspaceConfig = setupConfigProvider(workspaceFolder);
workspaceConfig.setup(w => w.inspect(TypeMoq.It.isValue('pythonPath'))).returns(() => undefined);

Expand Down

0 comments on commit 56f1fd1

Please sign in to comment.