Always update completion when cursor position changed
This commit is contained in:
parent
e741744f1d
commit
8914614f7b
@ -83,6 +83,7 @@ class Command(MinimalLineEdit):
|
|||||||
self.setValidator(self._validator)
|
self.setValidator(self._validator)
|
||||||
self.textEdited.connect(self.on_text_edited)
|
self.textEdited.connect(self.on_text_edited)
|
||||||
self.cursorPositionChanged.connect(self._update_cursor_part)
|
self.cursorPositionChanged.connect(self._update_cursor_part)
|
||||||
|
self.cursorPositionChanged.connect(self.on_cursor_position_changed)
|
||||||
self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Ignored)
|
self.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Ignored)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -116,7 +117,6 @@ class Command(MinimalLineEdit):
|
|||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def _update_cursor_part(self):
|
def _update_cursor_part(self):
|
||||||
"""Get the part index of the commandline where the cursor is over."""
|
"""Get the part index of the commandline where the cursor is over."""
|
||||||
old_cursor_part = self.cursor_part
|
|
||||||
cursor_pos = self.cursorPosition()
|
cursor_pos = self.cursorPosition()
|
||||||
if self.text()[cursor_pos-1:cursor_pos+1] == ' ':
|
if self.text()[cursor_pos-1:cursor_pos+1] == ' ':
|
||||||
logger.debug("Cursor between spaces")
|
logger.debug("Cursor between spaces")
|
||||||
@ -131,9 +131,6 @@ class Command(MinimalLineEdit):
|
|||||||
if cursor_pos <= len(part):
|
if cursor_pos <= len(part):
|
||||||
# foo| bar
|
# foo| bar
|
||||||
self.cursor_part = i
|
self.cursor_part = i
|
||||||
if old_cursor_part != i:
|
|
||||||
self.update_completion.emit(self.prefix, self.parts,
|
|
||||||
self.cursor_part)
|
|
||||||
logger.debug("Cursor part: {}".format(i))
|
logger.debug("Cursor part: {}".format(i))
|
||||||
if spaces:
|
if spaces:
|
||||||
logger.debug("Cursor between spaces -> queueing empty "
|
logger.debug("Cursor between spaces -> queueing empty "
|
||||||
@ -145,6 +142,11 @@ class Command(MinimalLineEdit):
|
|||||||
cursor_pos -= (len(part) + 1) # FIXME are spaces always 1 char?
|
cursor_pos -= (len(part) + 1) # FIXME are spaces always 1 char?
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
|
def on_cursor_position_changed(self):
|
||||||
|
"""Update completion when the cursor position changed."""
|
||||||
|
self.update_completion.emit(self.prefix, self.parts, self.cursor_part)
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def set_cmd_text(self, text):
|
def set_cmd_text(self, text):
|
||||||
"""Preset the statusbar to some text.
|
"""Preset the statusbar to some text.
|
||||||
|
Loading…
Reference in New Issue
Block a user