-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Zones: Support rules matching multiple results
Also fixes a rare issue where an async doc update moves the zone away from the caret without canceling zone restriction.
- Loading branch information
1 parent
09f4662
commit edc58eb
Showing
3 changed files
with
12 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
# See the file COPYING.txt at the root of this distribution for more details. | ||
|
||
|
||
__version__ = "2024.07.19" | ||
__version__ = "2024.07.22" | ||
__author__ = "Frédéric Brugnot <[email protected]>" | ||
|
||
|
||
|
@@ -381,7 +381,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: | ||
|
@@ -570,14 +572,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) | ||
) | ||
) | ||
) | ||
|
@@ -1597,6 +1599,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) | ||
|
||
|
@@ -1683,8 +1686,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) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ | |
), | ||
ZONE: ( | ||
"autoAction", | ||
"multiple", | ||
"formMode", | ||
"skip", | ||
"sayName", | ||
|