diff --git a/src/calibre/gui2/tweak_book/editor/comments.py b/src/calibre/gui2/tweak_book/editor/comments.py index f6460938c3..a4e139e71f 100644 --- a/src/calibre/gui2/tweak_book/editor/comments.py +++ b/src/calibre/gui2/tweak_book/editor/comments.py @@ -3,7 +3,7 @@ # License: GPLv3 Copyright: 2015, Kovid Goyal -from PyQt5.Qt import QTextCursor +from PyQt5.Qt import QTextCursor, QTextDocument opening_map = { 'css':'/*', @@ -24,10 +24,10 @@ def apply_smart_comment(editor, opening='/*', closing='*/', line_comment=None): doc = editor.document() c = QTextCursor(editor.textCursor()) c.clearSelection() - before_opening = doc.find(opening, c, doc.FindBackward | doc.FindCaseSensitively) - before_closing = doc.find(closing, c, doc.FindBackward | doc.FindCaseSensitively) - after_opening = doc.find(opening, c, doc.FindCaseSensitively) - after_closing = doc.find(closing, c, doc.FindCaseSensitively) + before_opening = doc.find(opening, c, QTextDocument.FindFlag.FindBackward | QTextDocument.FindFlag.FindCaseSensitively) + before_closing = doc.find(closing, c, QTextDocument.FindFlag.FindBackward | QTextDocument.FindFlag.FindCaseSensitively) + after_opening = doc.find(opening, c, QTextDocument.FindFlag.FindCaseSensitively) + after_closing = doc.find(closing, c, QTextDocument.FindFlag.FindCaseSensitively) in_block_comment = (not before_opening.isNull() and (before_closing.isNull() or before_opening.position() >= before_closing.position())) and \ (not after_closing.isNull() and (after_opening.isNull() or after_closing.position() <= after_opening.position())) if in_block_comment: