Move split_cmdline() out of commands.managers
This commit is contained in:
parent
0c1f611a72
commit
1d2d435231
@ -29,30 +29,6 @@ from qutebrowser.utils.misc import safe_shlex_split
|
|||||||
from qutebrowser.utils.log import commands as logger
|
from qutebrowser.utils.log import commands as logger
|
||||||
|
|
||||||
|
|
||||||
def split_cmdline(text):
|
|
||||||
"""Convenience function to split a commandline into it's logical parts.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
text: The string to split.
|
|
||||||
|
|
||||||
Return:
|
|
||||||
A list of strings.
|
|
||||||
"""
|
|
||||||
logger.debug("Splitting '{}'".format(text))
|
|
||||||
manager = CommandManager()
|
|
||||||
original_cmd = text.strip().split(maxsplit=1)
|
|
||||||
try:
|
|
||||||
parts = manager.parse(text)
|
|
||||||
except NoSuchCommandError:
|
|
||||||
parts = text.split(' ')
|
|
||||||
if text.endswith(' '):
|
|
||||||
parts.append('')
|
|
||||||
logger.debug("Split parts: {}".format(parts))
|
|
||||||
if len(parts) == 1 and parts[0]:
|
|
||||||
parts = original_cmd
|
|
||||||
return parts
|
|
||||||
|
|
||||||
|
|
||||||
class SearchManager(QObject):
|
class SearchManager(QObject):
|
||||||
|
|
||||||
"""Manage qutebrowser searches.
|
"""Manage qutebrowser searches.
|
||||||
|
@ -24,7 +24,8 @@ from PyQt5.QtGui import QValidator
|
|||||||
import qutebrowser.keyinput.modeman as modeman
|
import qutebrowser.keyinput.modeman as modeman
|
||||||
import qutebrowser.commands.utils as cmdutils
|
import qutebrowser.commands.utils as cmdutils
|
||||||
from qutebrowser.widgets.misc import MinimalLineEdit
|
from qutebrowser.widgets.misc import MinimalLineEdit
|
||||||
from qutebrowser.commands.managers import split_cmdline
|
from qutebrowser.commands.managers import CommandManager
|
||||||
|
from qutebrowser.commands.exceptions import NoSuchCommandError
|
||||||
from qutebrowser.keyinput.modeparsers import STARTCHARS
|
from qutebrowser.keyinput.modeparsers import STARTCHARS
|
||||||
from qutebrowser.utils.log import completion as logger
|
from qutebrowser.utils.log import completion as logger
|
||||||
from qutebrowser.models.cmdhistory import (History, HistoryEmptyError,
|
from qutebrowser.models.cmdhistory import (History, HistoryEmptyError,
|
||||||
@ -102,7 +103,20 @@ class Command(MinimalLineEdit):
|
|||||||
if not text:
|
if not text:
|
||||||
return []
|
return []
|
||||||
text = text[len(self.prefix):]
|
text = text[len(self.prefix):]
|
||||||
return split_cmdline(text)
|
logger.debug("Splitting '{}'".format(text))
|
||||||
|
manager = CommandManager()
|
||||||
|
original_cmd = text.strip().split(maxsplit=1)
|
||||||
|
try:
|
||||||
|
parts = manager.parse(text)
|
||||||
|
except NoSuchCommandError:
|
||||||
|
parts = text.split(' ')
|
||||||
|
if text.endswith(' '):
|
||||||
|
parts.append('')
|
||||||
|
logger.debug("Split parts: {}".format(parts))
|
||||||
|
if len(parts) == 1 and parts[0]:
|
||||||
|
parts = original_cmd
|
||||||
|
return parts
|
||||||
|
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def _update_cursor_part(self):
|
def _update_cursor_part(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user