Skip to content

Commit 6c18b02

Browse files
committed
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)
1 parent 2df665d commit 6c18b02

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • src/calibre/gui2/tweak_book/editor

src/calibre/gui2/tweak_book/editor/text.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,14 +625,21 @@ def go_to_anchor(self, anchor):
625625

626626
# Line numbers and cursor line {{{
627627
def highlight_cursor_line(self):
628+
self._highlight_cursor_line()
629+
630+
def _highlight_cursor_line(self, highlight_now=True):
631+
if self.highlighter.is_working:
632+
QTimer.singleShot(10, self.highlight_cursor_line)
633+
if not highlight_now:
634+
return
628635
sel = QTextEdit.ExtraSelection()
629636
sel.format.setBackground(self.palette().alternateBase())
630637
sel.format.setProperty(QTextFormat.Property.FullWidthSelection, True)
631638
sel.cursor = self.textCursor()
632639
sel.cursor.clearSelection()
633640
self.current_cursor_line = [sel]
634641

635-
# apply any formats that have a backgroud over the cursor line format
642+
# apply any formats that have a background over the cursor line format
636643
# to ensure they are visible
637644
c = self.textCursor()
638645
block = c.block()

0 commit comments

Comments
 (0)