forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Guide users to install workaround when deactivate command is run (#22223
- Loading branch information
Kartik Raj
authored
Oct 20, 2023
1 parent
a55484d
commit 0438813
Showing
29 changed files
with
979 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Same as deactivate in "<venv>/bin/activate" | ||
deactivate () { | ||
if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then | ||
PATH="${_OLD_VIRTUAL_PATH:-}" | ||
export PATH | ||
unset _OLD_VIRTUAL_PATH | ||
fi | ||
if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then | ||
PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}" | ||
export PYTHONHOME | ||
unset _OLD_VIRTUAL_PYTHONHOME | ||
fi | ||
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then | ||
hash -r 2> /dev/null | ||
fi | ||
if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then | ||
PS1="${_OLD_VIRTUAL_PS1:-}" | ||
export PS1 | ||
unset _OLD_VIRTUAL_PS1 | ||
fi | ||
unset VIRTUAL_ENV | ||
unset VIRTUAL_ENV_PROMPT | ||
if [ ! "${1:-}" = "nondestructive" ] ; then | ||
unset -f deactivate | ||
fi | ||
} | ||
|
||
# Initialize the variables required by deactivate function | ||
_OLD_VIRTUAL_PS1="${PS1:-}" | ||
_OLD_VIRTUAL_PATH="$PATH" | ||
if [ -n "${PYTHONHOME:-}" ] ; then | ||
_OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Same as deactivate in "<venv>/bin/activate.csh" | ||
alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate' | ||
|
||
# Initialize the variables required by deactivate function | ||
set _OLD_VIRTUAL_PROMPT="$prompt" | ||
set _OLD_VIRTUAL_PATH="$PATH" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Same as deactivate in "<venv>/bin/activate.fish" | ||
function deactivate -d "Exit virtual environment and return to normal shell environment" | ||
# reset old environment variables | ||
if test -n "$_OLD_VIRTUAL_PATH" | ||
set -gx PATH $_OLD_VIRTUAL_PATH | ||
set -e _OLD_VIRTUAL_PATH | ||
end | ||
if test -n "$_OLD_VIRTUAL_PYTHONHOME" | ||
set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME | ||
set -e _OLD_VIRTUAL_PYTHONHOME | ||
end | ||
|
||
if test -n "$vscode_python_old_fish_prompt_OVERRIDE" | ||
set -e vscode_python_old_fish_prompt_OVERRIDE | ||
if functions -q vscode_python_old_fish_prompt | ||
functions -e fish_prompt | ||
functions -c vscode_python_old_fish_prompt fish_prompt | ||
functions -e vscode_python_old_fish_prompt | ||
end | ||
end | ||
|
||
set -e VIRTUAL_ENV | ||
set -e VIRTUAL_ENV_PROMPT | ||
if test "$argv[1]" != "nondestructive" | ||
functions -e deactivate | ||
end | ||
end | ||
|
||
# Initialize the variables required by deactivate function | ||
set -gx _OLD_VIRTUAL_PATH $PATH | ||
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" | ||
functions -c fish_prompt vscode_python_old_fish_prompt | ||
end | ||
if set -q PYTHONHOME | ||
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Same as deactivate in "Activate.ps1" | ||
function global:deactivate ([switch]$NonDestructive) { | ||
if (Test-Path function:_OLD_VIRTUAL_PROMPT) { | ||
copy-item function:_OLD_VIRTUAL_PROMPT function:prompt | ||
remove-item function:_OLD_VIRTUAL_PROMPT | ||
} | ||
if (Test-Path env:_OLD_VIRTUAL_PYTHONHOME) { | ||
copy-item env:_OLD_VIRTUAL_PYTHONHOME env:PYTHONHOME | ||
remove-item env:_OLD_VIRTUAL_PYTHONHOME | ||
} | ||
if (Test-Path env:_OLD_VIRTUAL_PATH) { | ||
copy-item env:_OLD_VIRTUAL_PATH env:PATH | ||
remove-item env:_OLD_VIRTUAL_PATH | ||
} | ||
if (Test-Path env:VIRTUAL_ENV) { | ||
remove-item env:VIRTUAL_ENV | ||
} | ||
if (!$NonDestructive) { | ||
remove-item function:deactivate | ||
} | ||
} | ||
|
||
# Initialize the variables required by deactivate function | ||
if (! $env:VIRTUAL_ENV_DISABLE_PROMPT) { | ||
function global:_OLD_VIRTUAL_PROMPT {""} | ||
copy-item function:prompt function:_OLD_VIRTUAL_PROMPT | ||
} | ||
if (Test-Path env:PYTHONHOME) { | ||
copy-item env:PYTHONHOME env:_OLD_VIRTUAL_PYTHONHOME | ||
} | ||
copy-item env:PATH env:_OLD_VIRTUAL_PATH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import { ProgressOptions } from 'vscode'; | ||
import { Deferred, createDeferred } from '../utils/async'; | ||
import { IApplicationShell } from './types'; | ||
|
||
export class ProgressService { | ||
private deferred: Deferred<void> | undefined; | ||
|
||
constructor(private readonly shell: IApplicationShell) {} | ||
|
||
public showProgress(options: ProgressOptions): void { | ||
if (!this.deferred) { | ||
this.createProgress(options); | ||
} | ||
} | ||
|
||
public hideProgress(): void { | ||
if (this.deferred) { | ||
this.deferred.resolve(); | ||
this.deferred = undefined; | ||
} | ||
} | ||
|
||
private createProgress(options: ProgressOptions) { | ||
this.shell.withProgress(options, () => { | ||
this.deferred = createDeferred(); | ||
return this.deferred.promise; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.