summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--qutebrowser/mainwindow/prompt.py9
-rw-r--r--tests/unit/mainwindow/test_prompt.py10
2 files changed, 10 insertions, 9 deletions
diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py
index 40c6fde3a..d4f4336dc 100644
--- a/qutebrowser/mainwindow/prompt.py
+++ b/qutebrowser/mainwindow/prompt.py
@@ -728,7 +728,7 @@ class FilenamePrompt(_BasePrompt):
# The model needs to be sorted so we get the correct first/last index
self._file_model.directoryLoaded.connect(
lambda: self._file_model.sort(0))
-
+
def _get_valid_dirs(self, path):
dirs = []
try:
@@ -738,17 +738,16 @@ class FilenamePrompt(_BasePrompt):
hidden = self._to_complete not in index.data()
if not hidden:
dirs.append(index.data())
- # self._file_view.setRowHidden(index.row(), index.parent(), hidden)
except FileNotFoundError:
log.prompt.debug("Directory doesn't exist, can't \
get valid dirs")
-
+
return dirs
def _do_completion(self, idx, which):
filename = self._file_model.fileName(idx)
valid_dirs = self._get_valid_dirs(self._current_path)
- while not filename in valid_dirs and idx.isValid():
+ while idx.isValid() and not self._file_view.isRowHidden(idx.row(), idx.parent()):
if which == 'prev':
idx = self._file_view.indexAbove(idx)
else:
@@ -798,7 +797,7 @@ class FilenamePrompt(_BasePrompt):
# wrap around if we arrived at beginning/end
if not idx.isValid():
idx = last_index if which == 'prev' else first_index
-
+
idx = self._do_completion(idx, which)
selmodel.setCurrentIndex(
diff --git a/tests/unit/mainwindow/test_prompt.py b/tests/unit/mainwindow/test_prompt.py
index 8f32d6338..71d94e51d 100644
--- a/tests/unit/mainwindow/test_prompt.py
+++ b/tests/unit/mainwindow/test_prompt.py
@@ -95,20 +95,21 @@ class TestFileCompletion:
prompt.item_focus('next')
prompt.item_focus('next')
assert prompt._lineedit.text() == str(testdir / 'bar')
-
+
def test_filtering_path(self, qtbot, tmp_path, get_prompt):
testdir = tmp_path / 'test'
for directory in ['bar', 'foo', 'bat']:
(testdir / directory).mkdir(parents=True)
-
+
prompt = get_prompt(str(testdir) + os.sep)
# Make sure all directories are shown
num_rows = prompt._file_model.rowCount(prompt._root_index)
visible = []
for row in range(num_rows):
- index = prompt._file_model.index(row, 0, prompt._file_model.index(os.path.basename(prompt._lineedit.text())))
+ parent = prompt._file_model.index(os.path.basename(prompt._lineedit.text()))
+ index = prompt._file_model.index(row, 0, parent)
if prompt._file_view.isRowHidden(index.row(), index.parent()):
visible.append(index.data())
@@ -119,7 +120,8 @@ class TestFileCompletion:
num_rows = prompt._file_model.rowCount(prompt._root_index)
visible = []
for row in range(num_rows):
- index = prompt._file_model.index(row, 0, prompt._file_model.index(os.path.basename(prompt._lineedit.text())))
+ parent = prompt._file_model.index(os.path.basename(prompt._lineedit.text()))
+ index = prompt._file_model.index(row, 0, parent)
if prompt._file_view.isRowHidden(index.row(), index.parent()):
visible.append(index.data())