mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Only highlight cursor line after syntax highlighter is finished
This is because cursor line highlight relies on data from syntax highlighting (to apply background colors)
This commit is contained in:
parent
2df665d4e7
commit
6c18b02642
@ -625,6 +625,13 @@ class TextEdit(PlainTextEdit):
|
|||||||
|
|
||||||
# Line numbers and cursor line {{{
|
# Line numbers and cursor line {{{
|
||||||
def highlight_cursor_line(self):
|
def highlight_cursor_line(self):
|
||||||
|
self._highlight_cursor_line()
|
||||||
|
|
||||||
|
def _highlight_cursor_line(self, highlight_now=True):
|
||||||
|
if self.highlighter.is_working:
|
||||||
|
QTimer.singleShot(10, self.highlight_cursor_line)
|
||||||
|
if not highlight_now:
|
||||||
|
return
|
||||||
sel = QTextEdit.ExtraSelection()
|
sel = QTextEdit.ExtraSelection()
|
||||||
sel.format.setBackground(self.palette().alternateBase())
|
sel.format.setBackground(self.palette().alternateBase())
|
||||||
sel.format.setProperty(QTextFormat.Property.FullWidthSelection, True)
|
sel.format.setProperty(QTextFormat.Property.FullWidthSelection, True)
|
||||||
@ -632,7 +639,7 @@ class TextEdit(PlainTextEdit):
|
|||||||
sel.cursor.clearSelection()
|
sel.cursor.clearSelection()
|
||||||
self.current_cursor_line = [sel]
|
self.current_cursor_line = [sel]
|
||||||
|
|
||||||
# apply any formats that have a backgroud over the cursor line format
|
# apply any formats that have a background over the cursor line format
|
||||||
# to ensure they are visible
|
# to ensure they are visible
|
||||||
c = self.textCursor()
|
c = self.textCursor()
|
||||||
block = c.block()
|
block = c.block()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user