diff --git a/README.asciidoc b/README.asciidoc index 43b6b6fca..01b8cce80 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -162,6 +162,7 @@ Contributors, sorted by the number of commits in descending order: * John ShaggyTwoDope Jenkins * Peter Vilim * Tarcisio Fedrizzi +* Oliver Caldwell * Jonas Schürmann * Panagiotis Ktistakis * Jimmy diff --git a/qutebrowser/config/configtypes.py b/qutebrowser/config/configtypes.py index 177f55456..65ea745c1 100644 --- a/qutebrowser/config/configtypes.py +++ b/qutebrowser/config/configtypes.py @@ -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.") diff --git a/qutebrowser/misc/editor.py b/qutebrowser/misc/editor.py index 2fa9791e9..143eb0a9c 100644 --- a/qutebrowser/misc/editor.py +++ b/qutebrowser/misc/editor.py @@ -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) diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py index cacc898ee..3cdde6b95 100644 --- a/tests/unit/config/test_configtypes.py +++ b/tests/unit/config/test_configtypes.py @@ -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): diff --git a/tests/unit/misc/test_editor.py b/tests/unit/misc/test_editor.py index a005c265e..dbc4c51ed 100644 --- a/tests/unit/misc/test_editor.py +++ b/tests/unit/misc/test_editor.py @@ -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 @@ -71,6 +71,13 @@ class TestArg: editor._proc._proc.start.assert_called_with( "bin", ["foo", editor._filename, "bar"]) + def test_placeholder_inline(self, config_stub, editor): + """Test starting editor with placeholder arg inside of another arg.""" + config_stub.data['general']['editor'] = ['bin', 'foo{}', 'bar'] + editor.edit("") + editor._proc._proc.start.assert_called_with( + "bin", ["foo" + editor._filename, "bar"]) + class TestFileHandling: