Don't highlight tags in inactive files
This commit is contained in:
@@ -485,8 +485,9 @@ class NWIndex:
|
||||
|
||||
# For a tag, only the first value is accepted, the rest are ignored
|
||||
if tBits[0] == nwKeyWords.TAG_KEY and nBits > 1:
|
||||
if tBits[1] in self._tagsIndex:
|
||||
isGood[1] = self._tagsIndex.tagHandle(tBits[1]) == tHandle
|
||||
check, _ = self.parseValue(tBits[1])
|
||||
if check in self._tagsIndex:
|
||||
isGood[1] = self._tagsIndex.tagHandle(check) == tHandle
|
||||
else:
|
||||
isGood[1] = True
|
||||
return isGood
|
||||
|
||||
@@ -60,8 +60,8 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
|
||||
logger.debug("Create: GuiDocHighlighter")
|
||||
|
||||
self._tItem = None
|
||||
self._tHandle = None
|
||||
self._isInactive = False
|
||||
self._spellCheck = False
|
||||
self._spellErr = QTextCharFormat()
|
||||
|
||||
@@ -238,11 +238,10 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
def setHandle(self, tHandle: str) -> None:
|
||||
"""Set the handle of the currently highlighted document."""
|
||||
self._tHandle = tHandle
|
||||
self._tItem = SHARED.project.tree[tHandle]
|
||||
logger.debug(
|
||||
"Syntax highlighter %s for item '%s'",
|
||||
"enabled" if self._tItem else "disabled", tHandle
|
||||
self._isInactive = (
|
||||
item.isInactiveClass() if (item := SHARED.project.tree[tHandle]) else False
|
||||
)
|
||||
logger.debug("Syntax highlighter enabled for item '%s'", tHandle)
|
||||
return
|
||||
|
||||
##
|
||||
@@ -286,16 +285,16 @@ class GuiDocHighlighter(QSyntaxHighlighter):
|
||||
for n, bit in enumerate(bits):
|
||||
xPos = pos[n]
|
||||
xLen = len(bit)
|
||||
if not isGood[n]:
|
||||
self.setFormat(xPos, xLen, self._hStyles["codeinval"])
|
||||
elif n == 0:
|
||||
if n == 0 and isGood[n]:
|
||||
self.setFormat(xPos, xLen, self._hStyles["keyword"])
|
||||
else:
|
||||
elif isGood[n] and not self._isInactive:
|
||||
one, two = index.parseValue(bit)
|
||||
self.setFormat(xPos, len(one), self._hStyles["value"])
|
||||
if two:
|
||||
yPos = xPos + len(bit) - len(two)
|
||||
self.setFormat(yPos, len(two), self._hStyles["optional"])
|
||||
elif not self._isInactive:
|
||||
self.setFormat(xPos, xLen, self._hStyles["codeinval"])
|
||||
|
||||
# We never want to run the spell checker on keyword/values,
|
||||
# so we force a return here
|
||||
|
||||
@@ -294,6 +294,10 @@ def testCoreIndex_CheckThese(mockGUI, fncPath, mockRnd):
|
||||
assert index.parseValue("Jane | Jane Smith") == ("Jane", "Jane Smith")
|
||||
assert index.parseValue("Jane | Jane Smith") == ("Jane", "Jane Smith")
|
||||
|
||||
# Duplicates with Display Name
|
||||
assert index.checkThese(["@tag", "Jane | Jane Doe"], cHandle) == [True, True]
|
||||
assert index.checkThese(["@tag", "Jane | Jane Smith"], nHandle) == [True, False]
|
||||
|
||||
project.closeProject()
|
||||
|
||||
# END Test testCoreIndex_CheckThese
|
||||
|
||||
Reference in New Issue
Block a user