From 6f8a3c52166611e477224b05c85419a8df7c689d Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 22 Apr 2011 06:59:40 +0900 Subject: [PATCH] if clozing on a word boundary, ensure it's preserved --- aqt/editor.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/aqt/editor.py b/aqt/editor.py index 6c10aa79b..53c0aeec4 100644 --- a/aqt/editor.py +++ b/aqt/editor.py @@ -124,7 +124,12 @@ function wrap(front, back) { span.appendChild(content); s.removeAllRanges(); s.addRange(r); - setFormat('inserthtml', front + span.innerHTML + back); + var new_ = front + span.innerHTML + back; + var f = currentField.innerHTML; + if (f.length && f[f.length-1] === " ") { + new_ = " " + new_; + } + setFormat('inserthtml', new_); }; function setFields(fields, focusTo) {