diff --git a/addon/globalPlugins/webAccess/ruleHandler/__init__.py b/addon/globalPlugins/webAccess/ruleHandler/__init__.py index b75bd58d..3d17f655 100644 --- a/addon/globalPlugins/webAccess/ruleHandler/__init__.py +++ b/addon/globalPlugins/webAccess/ruleHandler/__init__.py @@ -388,7 +388,9 @@ def update(self, nodeManager=None, force=False): self._ready = True self.nodeManagerIdentifier = self.nodeManager.identifier if self.zone is not None: - if not self.zone.update(): + if not self.zone.update() or not self.zone.containsTextInfo( + self.nodeManager.treeInterceptor.makeTextInfo(textInfos.POSITION_CARET) + ): self.zone = None #logTime("update marker", t) if self.isReady: @@ -577,14 +579,14 @@ def _getIncrementalResult( or ( ( not respectZone - or self.zone.containsNode(result.node) + or self.zone.containsResult(result) ) and not ( # If respecting zone restriction or iterating # backwards relative to the caret position, # avoid returning the current zone itself. self.zone.name == result.rule.name - and self.zone.startOffset == result.node.offset + and self.zone.containsResult(result) ) ) ) @@ -1489,6 +1491,7 @@ def __init__(self, result): rule = result.rule self._ruleManager = weakref.ref(rule.ruleManager) self.name = rule.name + self.index = result.index super().__init__(startOffset=None, endOffset=None) self._update(result) @@ -1575,8 +1578,9 @@ def restrictTextInfo(self, info): def update(self): try: - result = next(self.ruleManager.iterResultsByName(self.name)) - except StopIteration: + # Result index is 1-based + result = self.ruleManager.iterResultsByName(self.name)[self.index - 1] + except IndexError: self.startOffset = self.endOffset = None return False return self._update(result) diff --git a/addon/globalPlugins/webAccess/ruleHandler/properties.py b/addon/globalPlugins/webAccess/ruleHandler/properties.py index 0f73e4e2..263f0146 100644 --- a/addon/globalPlugins/webAccess/ruleHandler/properties.py +++ b/addon/globalPlugins/webAccess/ruleHandler/properties.py @@ -78,7 +78,7 @@ class PropertySpec(Enum): isRestrictedChoice=True ) multiple = PropertySpecValue( - ruleTypes=("marker",), + ruleTypes=("marker", "zone"), valueType=bool, default=False, # Translators: The display name for a rule property