p5.js-web-editor icon indicating copy to clipboard operation
p5.js-web-editor copied to clipboard

Editor not helping: Bug

Open everythingability opened this issue 3 years ago • 5 comments

When using the Editor with auto-refresh checked, in a js library I have created (in the editor)... in my case app.js.

...when I type a mistake or have as yet unfinished code, the editor flags this up but I'm jumped to the sketch.js file, and so, often I'm in the middle of writing the code, and I add nonsense to a random point in my sketch.js file.

everythingability avatar Nov 18 '21 12:11 everythingability

Thank you for reporting! I think this has to do with a new feature I added to highlight runtime errors. Would you mind posting a link to the sketch that this is happening in?

Would you also be able to write out the steps to reproduce this bug (e.g. 1. Open a new sketch, 2. create a file called 'app.js', etc.)? Thank you so much!

catarak avatar Nov 18 '21 20:11 catarak

I think I just ran into this issue myself, where a runtime error was thrown in sketch.js because of a dependency on another file:

  1. Open the default sketch
  2. Add an other.js file and a <script> to include it before the sketch.js include
  3. Add blah = () => {} to other.js
  4. In setup in sketch.js, add a call to the blah() function
  5. Back in other.js, remove blah or redefine blah to no longer be a function. When auto-run, a runtime error is thrown at the call site in sketch.js, so the editor switches to sketch.js

Let me know if this isn't the same problem

anderoonies avatar Nov 28 '21 15:11 anderoonies

That's exactly the problem. @anderoonies

And what happens is, you go to fix the error and you type at some random spot (sometimes below the scroll) and all of a sudden you have two problem files, the one you coded a bug in an the one that has the first few chars of what you'd started to type at a random spot.

So bad, I had to stop using the Editor completely.

everythingability avatar Nov 29 '21 12:11 everythingability

Seems like a tricky problem, since the error really is in the other file. Maybe if file switching for runtime errors waits for you to stop typing of Auto-refresh is on, but that’s a pretty fuzzy metric

On Mon, Nov 29, 2021 at 4:24 AM everythingability @.***> wrote:

That's exactly the problem. @anderoonies https://github.com/anderoonies

And what happens is, you go to fix the error and you type at some random spot (sometimes below the scroll) and all of a sudden you have two problem files, the one you coded a bug in an the one that has the first few chars of what you'd started to type at a random spot.

So bad, I had to stop using the Editor completely.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/processing/p5.js-web-editor/issues/1976#issuecomment-981586957, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABSWLALVUOW6DFIYQXOZULTUONWIPANCNFSM5IJPQEJA .

anderoonies avatar Nov 29 '21 17:11 anderoonies

No it isnt.

The error isn't in another file if in your main sketch.js it calls a doThis() function, which is in another file... let's call it dothis.js.

So I'm editing code in dothis.js and I make a mistake, the error then JUMPS back to sketch.js where doThis() is called... and tap-tap-tap... there are now letters I'd started typing whilst in the doThis() function in sketch.js.

One "solution" might be to show the error (with a link to where it thinks the error is) and nothing else (whilst still polling the code as I type) and if the code eventually runs, hide the error.

(But I know NOTHING about how the Editor works and if this is just fantasy).

Cheers for trying though.

everythingability avatar Nov 29 '21 18:11 everythingability

Hi! As we're currently in the process of organizing issues and discussions, I'm going to close this issue since might not plan to focus on this in the near future. Thanks for your understanding and please feel free to reopen this or create a new one!

raclim avatar Dec 08 '22 14:12 raclim