diff --git a/Pipfile.lock b/Pipfile.lock index a9ead48..65b79de 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -92,12 +92,6 @@ "index": "pypi", "version": "==3.2.1" }, - "future": { - "hashes": [ - "sha256:b1bead90b70cf6ec3f0710ae53a525360fa360d306a86583adc6bf83a4db537d" - ], - "version": "==0.18.2" - }, "pycparser": { "hashes": [ "sha256:2d475327684562c3a96cc71adf7dc8c4f0565175cf86b6d7a404ff4c771f15f0", @@ -193,11 +187,11 @@ }, "sievelib": { "hashes": [ - "sha256:b6fe5d4239dab278def5eab9ece95463ea241c99b9ba6dc8ac452394a83f697b", - "sha256:bf1e684881483e33d4c37687d147ebbe85bd09fc3b0b6c7366aac992b97581ea" + "sha256:a34ffb27dffeebe4f540c85a0aaaa6588ff7fbeac11a81a0dba1ead54bf339c5", + "sha256:c98559705d7f8aa701d8a177120fea98f79e6d6dfecc076389738ab2d5ff05cb" ], "index": "pypi", - "version": "==1.1.1" + "version": "==1.2.0" }, "six": { "hashes": [ diff --git a/strainer/controls/statusbar.py b/strainer/controls/statusbar.py index 12c67cd..da9fb30 100644 --- a/strainer/controls/statusbar.py +++ b/strainer/controls/statusbar.py @@ -91,16 +91,8 @@ def parseScript(self, text=None): def getError(self, text): if text is None: return None, tuple() - try: - parseResult = self._parser.parse(text) - except Exception: - # Workaround for sievelib bug #96 - return (0, 0), 'Error occurred while trying to parse the script.' + parseResult = self._parser.parse(text) if parseResult: return None, 'No errors found in open script.' - # Workaround for sievelib bug #93 errorPos = tuple(x - 1 for x in self._parser.error_pos) - error = self._parser.error - if len(error) > 200: - error = error[:197] + ' [...]' - return errorPos, error + return errorPos, self._parser.error diff --git a/strainer/sieve/__init__.py b/strainer/sieve/__init__.py index 0bdd818..66bf830 100644 --- a/strainer/sieve/__init__.py +++ b/strainer/sieve/__init__.py @@ -1,17 +1,11 @@ -from sievelib.commands import ExistsCommand from sievelib.parser import Lexer, Parser from .connection import SieveConnectionQueue __all__ = ('SieveConnectionQueue',) -# Patch sievelib bug #90 -ExistsCommand.args_definition[0]['type'].append('string') - # Save error line and column on error -# Due to a problem in sievelib, column number is currently at the _end_ of a token, not the start. -# Cf. tonioo/sievelib#92 for a fix. @property def error(self): return self._error diff --git a/strainer/widgets/editor/lexer.py b/strainer/widgets/editor/lexer.py index 9142752..6dde4b3 100644 --- a/strainer/widgets/editor/lexer.py +++ b/strainer/widgets/editor/lexer.py @@ -127,10 +127,10 @@ def _doStyleText(self, start: int, end: int): self._stylingPos = 0 self.startStyling(start) for style, value in self.scan(start): - self.setStyling(self._lexer.pos - self._stylingPos - len(value), 0) + self.setStyling(self._lexer.pos - self._stylingPos, 0) self.setStyling(len(value), style) - self._stylingPos = self._lexer.pos - if start + self._lexer.pos > end: + self._stylingPos = self._lexer.pos + len(value) + if start + self._stylingPos > end: break def scan(self, start): @@ -145,7 +145,7 @@ def scan(self, start): command = get_command_instance(value.decode('ascii'), checkexists=False) style = self._IDENTIFIER_STYLES[command.get_type()] except (UnknownCommand, NotImplementedError, KeyError): - value_start = start + self._lexer.pos - len(value) + value_start = start + self._lexer.pos editor.SendScintilla(QsciScintilla.SCI_INDICATORFILLRANGE, value_start, len(value)) yield style, value diff --git a/strainer/widgets/editor/scintilla.py b/strainer/widgets/editor/scintilla.py index 87ced9d..895560c 100644 --- a/strainer/widgets/editor/scintilla.py +++ b/strainer/widgets/editor/scintilla.py @@ -86,7 +86,6 @@ def setParseError(self, line, col, length=1): self.SendScintilla(QsciScintilla.SCI_SETINDICATORCURRENT, 1) self.SendScintilla(QsciScintilla.SCI_INDICATORCLEARRANGE, 0, self.length()) if line >= 0 and col >= 0: - # check if max() is still needed after sievelib #92 is merged start = max(self.positionFromLineIndex(line, col) - length, 0) self.SendScintilla(QsciScintilla.SCI_INDICATORFILLRANGE, start, length)