After inserting a hyperlink restore text format

allows typing after inserting the link in the previous text style
This commit is contained in:
Kovid Goyal 2019-10-02 12:36:05 +05:30
parent 113be27352
commit 350494d016
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -576,6 +576,7 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{
if is_image:
c.insertImage(url)
else:
oldfmt = QTextCharFormat(c.charFormat())
fmt = QTextCharFormat()
fmt.setAnchor(True)
fmt.setAnchorHref(url)
@ -590,6 +591,8 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{
cur = self.textCursor()
cur.setPosition(i), cur.setPosition(i + 1, c.KeepAnchor)
cur.mergeCharFormat(fmt)
c.setPosition(c.position())
c.setCharFormat(oldfmt)
else:
error_dialog(self, _('Invalid URL'),