diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py index f489a81f0..5e686a375 100644 --- a/qutebrowser/mainwindow/prompt.py +++ b/qutebrowser/mainwindow/prompt.py @@ -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: diff --git a/tests/unit/mainwindow/test_prompt.py b/tests/unit/mainwindow/test_prompt.py index 98cd8b550..1288ccd3f 100644 --- a/tests/unit/mainwindow/test_prompt.py +++ b/tests/unit/mainwindow/test_prompt.py @@ -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() == '/'