Fix handling of / as path

This commit is contained in:
Florian Bruhin 2016-11-02 22:58:24 +01:00
parent 16b3b7a262
commit cbf1a44b75
2 changed files with 10 additions and 1 deletions

View File

@ -556,7 +556,10 @@ class FilenamePrompt(_BasePrompt):
dirname = os.path.dirname(path)
try:
if path[-1] in separators and os.path.isdir(path):
if path in separators and os.path.isdir(path):
# Input "/" -> don't strip anything
pass
elif path[-1] in separators and os.path.isdir(path):
# Input like /foo/bar/ -> show /foo/bar/ contents
path = path.rstrip(separators)
elif os.path.isdir(dirname) and not tabbed:

View File

@ -85,3 +85,9 @@ class TestFileCompletion:
prompt.item_focus('next')
prompt.item_focus('next')
assert prompt._lineedit.text() == str(tmpdir / 'bar')
@pytest.mark.linux
def test_root_path(self, get_prompt):
"""With / as path, show root contents."""
prompt = get_prompt('/')
assert prompt._file_model.rootPath() == '/'