diff --git a/editor.py b/editor.py index 6fc73f1..54a3760 100755 --- a/editor.py +++ b/editor.py @@ -8,8 +8,6 @@ import os.path import subprocess import tempfile -from distutils.spawn import find_executable - __all__ = [ 'edit', @@ -17,7 +15,7 @@ 'EditorError', ] -__version__ = '1.0.4' +__version__ = '1.0.5' class EditorError(RuntimeError): @@ -47,11 +45,28 @@ def get_editor_args(editor): elif editor == 'nano': return ['-R'] + elif editor == 'code': + return ["-w", "-n"] + else: return [] def get_editor(): + # The import from distutils needs to be here, at this low level to + # prevent import of 'editor' itself from breaking inquirer. This + # has to do with ubuntu (debian) python packages artificially + # separated from distutils. + # + # If this import is at top level inquirer breaks on ubuntu until + # the user explicitly apt-get install python3-distutils. With the + # import here it will only break if the code is utilizing the + # inquirer editor prompt. + try: + from distutils.spawn import find_executable + except ImportError: + from shutil import which as find_executable + # Get the editor from the environment. Prefer VISUAL to EDITOR editor = os.environ.get('VISUAL') or os.environ.get('EDITOR') if editor: diff --git a/setup.py b/setup.py index d1a9081..b0faf89 100755 --- a/setup.py +++ b/setup.py @@ -1,4 +1,4 @@ -__VERSION__ = '1.0.4' +__VERSION__ = '1.0.5' from setuptools import setup