mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
preserve text cursor when writing fields
This commit is contained in:
parent
a652a0979d
commit
8d3220ad3d
1 changed files with 3 additions and 1 deletions
|
@ -304,9 +304,11 @@ class FactEditor(object):
|
||||||
self.widgets[w] = field
|
self.widgets[w] = field
|
||||||
new = self.fact[field.name]
|
new = self.fact[field.name]
|
||||||
old = tidyHTML(unicode(w.toHtml()))
|
old = tidyHTML(unicode(w.toHtml()))
|
||||||
# only update if something has changed, to preserve the cursor
|
# only update if something has changed
|
||||||
if new != old:
|
if new != old:
|
||||||
|
cur = w.textCursor()
|
||||||
w.setHtml('<meta name="qrichtext" content="1"/>' + new)
|
w.setHtml('<meta name="qrichtext" content="1"/>' + new)
|
||||||
|
w.setTextCursor(cur)
|
||||||
if font:
|
if font:
|
||||||
# apply fonts
|
# apply fonts
|
||||||
font = QFont()
|
font = QFont()
|
||||||
|
|
Loading…
Reference in a new issue