mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-18 06:25:13 +02:00
DRYer
This commit is contained in:
@@ -223,20 +223,20 @@ def resolve_editor_cmd(editor: str, shell_env: Mapping[str, str]) -> Optional[st
|
|||||||
return editor
|
return editor
|
||||||
if not editor_exe:
|
if not editor_exe:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def patched(exe: str) -> str:
|
||||||
|
editor_cmd[0] = exe
|
||||||
|
return ' '.join(map(shlex.quote, editor_cmd))
|
||||||
|
|
||||||
if shell_env is os.environ:
|
if shell_env is os.environ:
|
||||||
q = find_exe(editor_exe)
|
q = find_exe(editor_exe)
|
||||||
if q:
|
if q:
|
||||||
editor_cmd[0] = q
|
return patched(q)
|
||||||
editor = ' '.join(map(shlex.quote, editor_cmd))
|
elif 'PATH' in shell_env:
|
||||||
return editor
|
|
||||||
return None
|
|
||||||
if 'PATH' in shell_env:
|
|
||||||
import shlex
|
import shlex
|
||||||
q = shutil.which(editor_exe, path=shell_env['PATH'])
|
q = shutil.which(editor_exe, path=shell_env['PATH'])
|
||||||
if q:
|
if q:
|
||||||
editor_cmd[0] = q
|
return patched(q)
|
||||||
editor = ' '.join(map(shlex.quote, editor_cmd))
|
|
||||||
return editor
|
|
||||||
|
|
||||||
|
|
||||||
def get_editor_from_env(shell_env: Mapping[str, str]) -> Optional[str]:
|
def get_editor_from_env(shell_env: Mapping[str, str]) -> Optional[str]:
|
||||||
|
|||||||
Reference in New Issue
Block a user