mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 23:42:23 -04:00
fix cloze undo
This commit is contained in:
parent
f6a1a8fc63
commit
4607d42c5f
1 changed files with 4 additions and 2 deletions
|
@ -680,7 +680,9 @@ class FactEditor(object):
|
|||
re2 = "\[(.+?)(:.+?)?\]"
|
||||
# add brackets because selected?
|
||||
cursor = src.textCursor()
|
||||
oldSrc = None
|
||||
if cursor.hasSelection():
|
||||
oldSrc = src.toHtml()
|
||||
s = cursor.selectionStart()
|
||||
e = cursor.selectionEnd()
|
||||
cursor.setPosition(e)
|
||||
|
@ -703,6 +705,7 @@ class FactEditor(object):
|
|||
if dst == w:
|
||||
return
|
||||
# check if there's alredy something there
|
||||
if not oldSrc:
|
||||
oldSrc = src.toHtml()
|
||||
oldDst = dst.toHtml()
|
||||
if unicode(dst.toPlainText()):
|
||||
|
@ -734,7 +737,6 @@ class FactEditor(object):
|
|||
new = re.sub(re1, repl, s)
|
||||
old = re.sub(re2, '<font color="%s"><b>\\1</b></font>'
|
||||
% clozeColour, s)
|
||||
oldSrc = unicode(src.toHtml())
|
||||
src.setHtml(new)
|
||||
dst.setHtml(old)
|
||||
self.lastCloze = (oldSrc, unicode(src.toHtml()),
|
||||
|
|
Loading…
Reference in a new issue