Skip to content

Commit

Permalink
Merge pull request #27 from derula/dependabot/pip/sievelib-1.2.0
Browse files Browse the repository at this point in the history
Bump sievelib from 1.1.1 to 1.2.0
  • Loading branch information
derula authored Oct 30, 2020
2 parents 7e1d169 + 8f203bf commit 8fb6a0a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 30 deletions.
12 changes: 3 additions & 9 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 2 additions & 10 deletions strainer/controls/statusbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 0 additions & 6 deletions strainer/sieve/__init__.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 4 additions & 4 deletions strainer/widgets/editor/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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

Expand Down
1 change: 0 additions & 1 deletion strainer/widgets/editor/scintilla.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 8fb6a0a

Please sign in to comment.