diff --git a/qutebrowser/widgets/completion.py b/qutebrowser/widgets/completion.py index bb50e8f04..6d1cb8742 100644 --- a/qutebrowser/widgets/completion.py +++ b/qutebrowser/widgets/completion.py @@ -63,8 +63,8 @@ class CompletionView(QTreeView): _delegate: The item delegate used. Signals: - append_cmd_text: Command text which should be appended to the - statusbar. + change_completed_part: Text which should be substituted for the word + we're currently completing. """ @@ -98,7 +98,7 @@ class CompletionView(QTreeView): # like one anymore # FIXME somehow only the first column is yellow, even with # setAllColumnsShowFocus - append_cmd_text = pyqtSignal(str) + change_completed_part = pyqtSignal(str) def __init__(self, parent=None): super().__init__(parent) @@ -250,7 +250,7 @@ class CompletionView(QTreeView): shift: Whether shift is pressed or not. Emit: - append_cmd_text: When a command text should be set/appended. + change_completed_part: When a completion took place. """ if not self._completing: @@ -262,7 +262,7 @@ class CompletionView(QTreeView): data = self._model.data(idx) if data is not None: self._ignore_next = True - self.append_cmd_text.emit(self._model.data(idx)) + self.change_completed_part.emit(self._model.data(idx)) class _CompletionItemDelegate(QStyledItemDelegate): diff --git a/qutebrowser/widgets/mainwindow.py b/qutebrowser/widgets/mainwindow.py index 754beb8fb..a9796907d 100644 --- a/qutebrowser/widgets/mainwindow.py +++ b/qutebrowser/widgets/mainwindow.py @@ -91,8 +91,8 @@ class MainWindow(QWidget): self.status.cmd.textChanged.connect( self.completion.on_cmd_text_changed) self.status.cmd.tab_pressed.connect(self.completion.on_tab_pressed) - self.completion.append_cmd_text.connect( - self.status.cmd.on_append_cmd_text) + self.completion.change_completed_part.connect( + self.status.cmd.on_change_completed_part) #self.retranslateUi(MainWindow) #self.tabWidget.setCurrentIndex(0) diff --git a/qutebrowser/widgets/statusbar.py b/qutebrowser/widgets/statusbar.py index e610e794c..a02a3fbfe 100644 --- a/qutebrowser/widgets/statusbar.py +++ b/qutebrowser/widgets/statusbar.py @@ -29,6 +29,7 @@ from qutebrowser.config.style import get_stylesheet import qutebrowser.commands.keys as keys from qutebrowser.utils.url import urlstring from qutebrowser.utils.usertypes import NeighborList +from qutebrowser.commands.parsers import split_cmdline class StatusBar(QWidget): @@ -376,14 +377,17 @@ class _Command(QLineEdit): self.show_cmd.emit() @pyqtSlot(str) - def on_append_cmd_text(self, text): - """Append text to the commandline. + def on_change_completed_part(self, text): + """Change the part we're currently completing in the commandline. Args: text: The text to set (string). """ - self.setText(self.text() + text) + # FIXME we should consider the cursor position. + parts = split_cmdline(self.text()) + parts[-1] = text + self.setText(':' + ' '.join(parts)) self.setFocus() self.show_cmd.emit()