Commit 1707b146 authored by Link Mauve's avatar Link Mauve

tabs.rostertab: Use Path for file completion.

parent 150feda3
......@@ -15,6 +15,7 @@ import os
import ssl
from os import getenv, path
from functools import partial
from pathlib import Path
from poezio import common
from poezio import windows
......@@ -612,27 +613,27 @@ class RosterInfoTab(Tab):
home = os.getenv('HOME') or '/'
return Completion(
the_input.new_completion, [home, '/tmp'], n, quotify=True)
path_ = args[n]
if path.isdir(path_):
path_ = Path(args[n])
if path_.is_dir():
dir_ = path_
base = ''
dir_ = path.dirname(path_)
base = path.basename(path_)
dir_ = path_.parent
base =
names = os.listdir(dir_)
names = list(dir_.iterdir())
except OSError:
names = []
names_filtered = [name for name in names if name.startswith(base)]
names_filtered = [name for name in names if str(name).startswith(base)]
if names_filtered:
names = names_filtered
if not names:
names = [path_]
end_list = []
for name in names:
value = os.path.join(dir_, name)
if not name.startswith('.'):
if not str(name).startswith('.'):
value = dir_ / name
return Completion(
the_input.new_completion, end_list, n, quotify=True)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment