From 85fbe27fd8c055da9820995e5e325b2e7f61087f Mon Sep 17 00:00:00 2001 From: Casey Date: Wed, 7 Oct 2020 00:30:50 +0800 Subject: [PATCH] #35 fixs the issue of formatting in tag views. --- widgets/Highlighter.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/widgets/Highlighter.py b/widgets/Highlighter.py index 85c40ed..20666e8 100644 --- a/widgets/Highlighter.py +++ b/widgets/Highlighter.py @@ -50,16 +50,21 @@ def highlightBlock(self, text): if self.editor.viewManager.isTagView(): # format text string textLen = len(token.text) - textStart = (token.start - currentBlock.position()) + if token.start == 0: + textStart = (token.start - currentBlock.position()) + else: + textStart = tagStart + tagSpan + 1 textSpan = textLen if token.level in highlightedLevels: self.setFormat(textStart, textSpan, format) # format tags tagFormat = self.editor.formatManager.TAG_FORMAT - tagStart = ( - token.start - currentBlock.position()) + textLen - tagSpan = token.length - textLen +# tagStart = ( +# token.start - currentBlock.position()) + textLen + tagStart = textStart + textSpan + 1 +# tagSpan = token.length - textLen + tagSpan = 1 + len(token.pos) self.setFormat(tagStart, tagSpan, tagFormat) else: # 可輸入文字的 View