Add RELEASE_CWD_ON_WIN environment variable

This commit is contained in:
Morten Enemark Lund 2017-03-09 10:23:55 +01:00
parent 0ccadf627a
commit 018ce10b0b
2 changed files with 13 additions and 1 deletions

View file

@ -159,6 +159,7 @@ def DEFAULT_ENSURERS():
'PRETTY_PRINT_RESULTS': (is_bool, to_bool, bool_to_str),
'PROMPT': (is_string_or_callable, ensure_string, ensure_string),
'RAISE_SUBPROC_ERROR': (is_bool, to_bool, bool_to_str),
'RELEASE_CWD_ON_WIN': (is_bool, to_bool, bool_to_str),
'RIGHT_PROMPT': (is_string_or_callable, ensure_string, ensure_string),
'BOTTOM_TOOLBAR': (is_string_or_callable, ensure_string, ensure_string),
'SUBSEQUENCE_PATH_COMPLETION': (is_bool, to_bool, bool_to_str),
@ -297,6 +298,7 @@ def DEFAULT_VALUES():
'PUSHD_MINUS': False,
'PUSHD_SILENT': False,
'RAISE_SUBPROC_ERROR': False,
'RELEASE_CWD_ON_WIN': False,
'RIGHT_PROMPT': '',
'BOTTOM_TOOLBAR': '',
'SHELL_TYPE': 'best',
@ -536,6 +538,15 @@ def DEFAULT_DOCS():
'This is most useful in xonsh scripts or modules where failures '
'should cause an end to execution. This is less useful at a terminal. '
'The error that is raised is a ``subprocess.CalledProcessError``.'),
'RELEASE_CWD_ON_WIN': VarDocs(
'This will release the lock on the current directory whenever the '
'prompt is shown. Enabling this will allow the other programs or '
'Windows Explorer to delete or rename the current or parent '
'directories. Internally, it is accomplished by temporarily resetting '
'CWD to the root drive folder while waiting at the prompt. So it can '
'cause problems if any extensions are enabled which hooks the prompt '
'and relies on ``os.getcwd()``.',configurable=ON_WINDOWS
),
'RIGHT_PROMPT': VarDocs(
'Template string for right-aligned text '
'at the prompt. This may be parameterized in the same way as '

View file

@ -93,7 +93,8 @@ class PromptToolkitShell(BaseShell):
get_rprompt_tokens = self.rprompt_tokens
get_bottom_toolbar_tokens = self.bottom_toolbar_tokens
if ON_WINDOWS and not env.get('UPDATE_PROMPT_ON_KEYPRESS'):
if (ON_WINDOWS and env.get('RELEASE_CWD_ON_WIN') and
not env.get('UPDATE_PROMPT_ON_KEYPRESS')):
# Wrap the prompt method to release the cwd while showing the prompt
self.prompter.prompt = cwd_release_wrapper(self.prompter.prompt)
if self.completer: