]> matita.cs.unibo.it Git - helm.git/commitdiff
Matitaweb: Bugfix for TeX-macro conversion.
authorWilmer Ricciotti <ricciott@cs.unibo.it>
Thu, 14 Jul 2011 14:57:04 +0000 (14:57 +0000)
committerWilmer Ricciotti <ricciott@cs.unibo.it>
Thu, 14 Jul 2011 14:57:04 +0000 (14:57 +0000)
matitaB/matita/matitaweb.js

index 0805e0b9adc297d1e1b5e144388691def7aa4785..3400c87e6e944e8e1d71ad6371d508ad7b38bfdd 100644 (file)
@@ -108,7 +108,7 @@ function suppressdefault(e,flag)
    return !flag;
 }
 
-function restoreSelection() {
+function restoreSelection(adjust) {
     unlocked.focus();
     if (savedRange != null) {
         if (window.getSelection)//non IE and there is already a selection
@@ -117,7 +117,7 @@ function restoreSelection() {
             if (s.rangeCount > 0) 
                 s.removeAllRanges();
            range = document.createRange();
-           range.setStart(savedsc,savedso);
+           range.setStart(savedsc,savedso + adjust);
            range.collapse(true);
             s.addRange(range);
         }
@@ -156,11 +156,11 @@ function keypress(e)
          sym = lookup_tex(match);
          if (typeof sym != "undefined") {
              unlocked.innerHTML = pre + sym + " " + post;
-             restoreSelection(); 
+             restoreSelection(sym.length - match.length); 
             return suppressdefault(e,true);
          }
          else {
-             restoreSelection(); 
+             // restoreSelection(0); 
             return suppressdefault(e,false);
          }
        }