Expand ~ when resolving editor path and applying exe_search_path

This commit is contained in:
pagedown 2022-07-26 13:21:50 +08:00
parent 1eef584382
commit 28ae8c4d20
No known key found for this signature in database
GPG Key ID: E921CF18AC8FF6EB
2 changed files with 6 additions and 3 deletions

View File

@ -82,6 +82,8 @@ Detailed list of changes
- remote files kitten: Fix working with files whose names have characters that
need to be quoted in shell scripts (:iss:`5313`)
- Expand ~ in paths configured in :opt:`editor` and :opt:`exe_search_path` (:disc:`5298`)
0.25.2 [2022-06-07]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -670,6 +670,7 @@ def get_editor(opts: Optional[Options] = None, path_to_edit: str = '', line_numb
else:
import shlex
ans = shlex.split(opts.editor)
ans[0] = os.path.expanduser(ans[0])
if path_to_edit:
if line_number:
eq = os.path.basename(ans[0]).lower()
@ -778,11 +779,11 @@ def which(name: str, only_system: bool = False) -> Optional[str]:
x = x.strip()
if x:
if x[0] == '-':
tried_paths.add(x[1:])
tried_paths.add(os.path.expanduser(x[1:]))
elif x[0] == '+':
append_paths.append(x[1:])
append_paths.append(os.path.expanduser(x[1:]))
else:
paths.append(x)
paths.append(os.path.expanduser(x))
ep = os.environ.get('PATH')
if ep:
paths.extend(ep.split(os.pathsep))