Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/present: editable code is not sync'd between main slide and presenter slide #26177

Open
jtirtawangsa opened this issue Jul 2, 2018 · 0 comments

Comments

Projects
None yet
3 participants
@jtirtawangsa
Copy link

commented Jul 2, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.10.2 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"

What did you do?

Using go "present -notes" to show editing some codes in the editable .code/.play presentation slides with presenter notes window active.

What did you expect to see?

The edited codes are synced between the main window and the presenter window.

What did you see instead?

The edited code is not synced between the two windows. The changes are only shown in the active window, i.e. If editing process in the main window, the codes in the presenter window do not change, and vice versa.

Notes:

Bug in golang.org/x/tools/cmd/present/static/slides.js
Function setupPlayCodeSync adds EventListener in a loop using variable index i (probably expecting the inputHandler function is instantiated for each Listener).
It is not, there is only one instant of inputHandler, and the variable i will contain the last value of i, which is play.length.

One solution to this is as follow (Javascript coders probably could give better solution):

--- golang.org/x/tools/cmd/present/static/slides-orig.js	2017-09-20 21:24:06.052672029 +0700
+++ golang.org/x/tools/cmd/present/static/slides.js	2018-07-02 17:41:45.431850356 +0700
@@ -578,9 +578,10 @@
     var play = document.querySelectorAll('div.playground');
     for (var i = 0; i < play.length; i++) {
       play[i].addEventListener('input', inputHandler, false);
+      play[i].setAttribute('play-index', i);
 
       function inputHandler(e) {
-        localStorage.setItem('play-index', i);
+        localStorage.setItem('play-index', e.target.getAttribute('play-index'));
         localStorage.setItem('play-code', e.target.innerHTML);
       }
     }

@ALTree ALTree changed the title Go present program: Editable code is not sync'd between main slide and presenter slide x/tools/present: editable code is not sync'd between main slide and presenter slide Jul 2, 2018

@gopherbot gopherbot added this to the Unreleased milestone Jul 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.