Skip to content

Commit 97090d7

Browse files
committed
Prefer VISUAL to EDITOR
Also, use environ.get() instead of os.path.expandvars()
1 parent 801a228 commit 97090d7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

editor.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ def get_platform_editor_var():
5050

5151

5252
def get_editor():
53-
env_editor = os.path.expandvars('$EDITOR')
54-
if env_editor != '$EDITOR' and env_editor.strip():
55-
return env_editor
53+
# Get the editor from the environment. Prefer VISUAL to EDITOR
54+
editor = os.environ.get('VISUAL') or os.environ.get('EDITOR')
55+
if editor:
56+
return editor
5657

58+
# None found in the environment. Fallback to platform-specific defaults.
5759
for ed in get_default_editors():
5860
path = find_executable(ed)
5961
if path is not None:

0 commit comments

Comments
 (0)