diff --git a/src/commands.py b/src/commands.py index ef3d2c043..7747589a8 100644 --- a/src/commands.py +++ b/src/commands.py @@ -1,6 +1,6 @@ ### # Copyright (c) 2002-2005, Jeremiah Fincher -# Copyright (c) 2009-2010, James McCoy +# Copyright (c) 2009-2010,2015, James McCoy # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -375,8 +375,8 @@ def _getRe(f): else: state.args.append(s) else: - state.errorInvalid('regular expression', s) - except IndexError: + raise ValueError + except (ValueError, IndexError): args[:] = original state.errorInvalid('regular expression', s) return get diff --git a/test/test_commands.py b/test/test_commands.py index 31c9a04fc..cc94c8c1f 100644 --- a/test/test_commands.py +++ b/test/test_commands.py @@ -1,5 +1,6 @@ ### # Copyright (c) 2002-2005, Jeremiah Fincher +# Copyright (c) 2015, James McCoy # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -181,5 +182,9 @@ class FirstTestCase(CommandsTestCase): self.assertStateErrored([first('int', 'something')], ['words'], errored=False) + def testLongRegexp(self): + spec = [first('regexpMatcher', 'regexpReplacer'), 'text'] + self.assertStateErrored(spec, ['s/foo/bar/', 'x' * 512], errored=False) + # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: