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

Editor::setValue can fail silently in text mode #137

Open
islemaster opened this issue Nov 5, 2015 · 1 comment
Open

Editor::setValue can fail silently in text mode #137

islemaster opened this issue Nov 5, 2015 · 1 comment

Comments

@islemaster
Copy link

In some situations, calling Editor::setValue will have no effect.

Ran across this issue on our site with our "Start Over" feature. Repro was starting a level, switching from block mode to text mode, typing a few lines, and then clicking "Start Over."

Root cause seems to be an outdated @lastAceSeenValue. This check is not checking the current value of the editor, because it's only updated when getAceValue is called, which does not include when typing into the editor. Thus the function can mistakenly think no change is needed, when in fact it is.

Either this check should query the actual current value of the ace editor, or it might not be necessary at all - hopefully Ace swallows redundant set calls internally.

@islemaster
Copy link
Author

Here's a simple repro:

  1. Start the live-reload server and open example.html
  2. Open your browser JavaScript console and run editor.setValue("foo");. This works.
  3. Type "bar" into the editor so that it now reads "foobar".
  4. Run editor.setValue("foo"); again. This time it has no effect. Expected: The editor text changes to "foo".

repro

islemaster added a commit to code-dot-org/code-dot-org that referenced this issue Feb 17, 2018
...for a Droplet bug,
See droplet-editor/droplet#137
Calling getValue() updates the cached ace editor value, which can be out-of-date in droplet and cause an incorrect early-out.
Could remove this line once that bug is fixed and Droplet is updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant