Merge branch 'relax-editor-templating' of https://github.com/Olical/qutebrowser into Olical-relax-editor-templating
This commit is contained in:
commit
ad290e8702
@ -1094,7 +1094,7 @@ class ShellCommand(BaseType):
|
||||
shlex.split(value)
|
||||
except ValueError as e:
|
||||
raise configexc.ValidationError(value, str(e))
|
||||
if self.placeholder and '{}' not in self.transform(value):
|
||||
if self.placeholder and '{}' not in value:
|
||||
raise configexc.ValidationError(value, "needs to contain a "
|
||||
"{}-placeholder.")
|
||||
|
||||
|
@ -124,6 +124,6 @@ class ExternalEditor(QObject):
|
||||
self._proc.error.connect(self.on_proc_error)
|
||||
editor = config.get('general', 'editor')
|
||||
executable = editor[0]
|
||||
args = [self._filename if arg == '{}' else arg for arg in editor[1:]]
|
||||
args = [arg.replace('{}', self._filename) for arg in editor[1:]]
|
||||
log.procs.debug("Calling \"{}\" with args {}".format(executable, args))
|
||||
self._proc.start(executable, args)
|
||||
|
@ -1580,14 +1580,16 @@ class TestShellCommand:
|
||||
({'none_ok': True}, ''),
|
||||
({}, 'foobar'),
|
||||
({'placeholder': '{}'}, 'foo {} bar'),
|
||||
({'placeholder': '{}'}, 'foo{}bar'),
|
||||
({'placeholder': '{}'}, 'foo "bar {}"'),
|
||||
])
|
||||
def test_validate_valid(self, klass, kwargs, val):
|
||||
klass(**kwargs).validate(val)
|
||||
|
||||
@pytest.mark.parametrize('kwargs, val', [
|
||||
({}, ''),
|
||||
({'placeholder': '{}'}, 'foo{} bar'),
|
||||
({'placeholder': '{}'}, 'foo bar'),
|
||||
({'placeholder': '{}'}, 'foo { } bar'),
|
||||
({}, 'foo"'), # not splittable with shlex
|
||||
])
|
||||
def test_validate_invalid(self, klass, kwargs, val):
|
||||
|
@ -57,7 +57,7 @@ class TestArg:
|
||||
editor: The ExternalEditor instance to test.
|
||||
"""
|
||||
|
||||
@pytest.mark.parametrize('args', [[], ['foo', 'bar'], ['foo{}bar']])
|
||||
@pytest.mark.parametrize('args', [[], ['foo'], ['foo', 'bar']])
|
||||
def test_start_no_placeholder(self, config_stub, editor, args):
|
||||
"""Test starting editor without arguments."""
|
||||
config_stub.data['general']['editor'] = ['bin'] + args
|
||||
|
Loading…
Reference in New Issue
Block a user