@@ -138,10 +138,12 @@ function syncAppState(appState) {
138138 // form update events while we set the code mirror value. otherwise
139139 // this will send an incorrect delta to the other end and screw things
140140 // up because the initial states of the two forms aren't equal.
141- var orig = TogetherJS . config . get ( 'ignoreForms' ) ;
142- TogetherJS . config ( 'ignoreForms' , true ) ;
143- pyInputSetValue ( appState . code ) ;
144- TogetherJS . config ( 'ignoreForms' , orig ) ;
141+ if ( useCodeMirror ) {
142+ var orig = TogetherJS . config . get ( 'ignoreForms' ) ;
143+ TogetherJS . config ( 'ignoreForms' , true ) ;
144+ pyInputSetValue ( appState . code ) ;
145+ TogetherJS . config ( 'ignoreForms' , orig ) ;
146+ }
145147
146148 if ( appState . rawInputLst ) {
147149 rawInputLst = $ . parseJSON ( appState . rawInputLstJSON ) ;
@@ -384,8 +386,12 @@ function initTogetherJS() {
384386 TogetherJS . hub . on ( "codeInputScroll" , function ( msg ) {
385387 // do NOT use a msg.sameUrl guard since that will miss some signals
386388 // due to our funky URLs
387-
388- pyInputSetScrollTop ( msg . scrollTop ) ;
389+ if ( useCodeMirror ) {
390+ pyInputSetScrollTop ( msg . scrollTop ) ;
391+ }
392+ else {
393+ // don't sync for Ace since I can't get it working properly yet
394+ }
389395 } ) ;
390396
391397 TogetherJS . hub . on ( "pyCodeOutputDivScroll" , function ( msg ) {
@@ -557,7 +563,8 @@ function pyInputSetValue(dat) {
557563 pyInputCodeMirror . setValue ( dat . rtrim ( ) /* kill trailing spaces */ ) ;
558564 }
559565 else {
560- pyInputAceEditor . setValue ( dat . rtrim ( ) /* kill trailing spaces */ ) ;
566+ pyInputAceEditor . setValue ( dat . rtrim ( ) /* kill trailing spaces */ ,
567+ - 1 /* do NOT select after setting text */ ) ;
561568 }
562569
563570 $ ( '#urlOutput,#embedCodeOutput' ) . val ( '' ) ;
@@ -648,13 +655,17 @@ function genericOptFrontendReady() {
648655 } ) ;
649656 }
650657 else {
658+ // don't do any syncing on change for Ace, since I can't get it to
659+ // behave quite like the CodeMirror version
660+ /*
651661 pyInputAceEditor.getSession().on("change", function(e) {
652662 // unfortunately, Ace doesn't detect whether a change was caused
653663 // by a setValue call
654664 if (TogetherJS.running) {
655665 TogetherJS.send({type: "codemirror-edit"});
656666 }
657667 });
668+ */
658669 }
659670
660671
@@ -674,19 +685,21 @@ function genericOptFrontendReady() {
674685 } ) ;
675686 }
676687 else {
677- var s = pyInputAceEditor . getSession ( ) ;
678- s . on ( 'changeScrollTop' , function ( ) {
688+ // don't sync for Ace since I can't get it working properly yet
689+ /*
690+ pyInputAceEditor.getSession().on('changeScrollTop', function() {
679691 if (TogetherJS.running) {
680692 $.doTimeout('codeInputScroll', 100, function() { // debounce
681693 // note that this will send a signal back and forth both ways
682694 // (there's no easy way to prevent this), but it shouldn't keep
683695 // bouncing back and forth indefinitely since no the second signal
684696 // causes no additional scrolling
685697 TogetherJS.send({type: "codeInputScroll",
686- scrollTop : s . getScrollTop ( ) } ) ;
698+ scrollTop: pyInputGetScrollTop ()});
687699 });
688700 }
689701 });
702+ */
690703 }
691704
692705
0 commit comments