Losing code, Editor quirks

Hello all,

1)With Codea 3.0, and with my project file stored in the Working Copy directory, I am experiencing issues where I will run the project, then return back to the code, then maybe try to run it again and return to code, and it seems to have lost recent changes that I had made. This isn’t a proper bug report, as I haven’t yet put a finger on exactly how to reproduce it. I just know I’ve lost some code this way a handful of times today, and I’m wondering if this is a known issue. I will try to pin down a sequence to reproduce the issue.

With the previous version, I never had an issue like this. Code I wrote was code that stayed.

  1. The editor isn’t consistently ‘behaving’ properly - for example, I’ll tap return after entering function foo() and Codea doesn’t always auto add the end keyword. It also is not always auto-indenting lines within a code block.

Just an update: long press save (see @Simeon ‘s comment above, is not fixing my problem…

I just spent a few cycles of tweaking a function, then long-press saving and running, and not seeing results I would expect. Once I added some obvious print statements and didn’t see them, I decided to exit the project and reopen. Sure enough, there was an older version of my code, and that was the version that had been running each time. The code shown in the editor was not what was getting executed. After each run attempt and return to the editor, I would see my changes in the editor, but none of it would affect program behavior.

@brianolive What level of 3.0 code are you running. I mentioned the missing end keyword and left justification problem in the Codea version 184 discussion. As far as I know it was fixed and I haven’t seen it since. As for the missing code, I think I remember that happening but I’m not sure what version that was in and if that was also fixed. I’m not sure if it has happened recently. I’m currently running Codea 3.0.1 version 187.

Version showing as 3.0 (187).

Project being in working copy doesn’t seem to have anything to do with it. It just happened with a project stored in the Codea folder.

I’m not doing a good job tonight of tracking what leads up to the problem! Each time it happens, I don’t clearly recall what I did right before it happens…to be continued…

All,
I wonder if this is tied in with the disappearing keyboard. Recently found the keyboard not being launched after tapping an input or the screen in the editor. Seemed to happen when I had left the editor for a while. Closing project and re-opening needed to resume normal editing.

@brianolive are you using the feature where you can drag-and-drop sprites or shaders into code? Because there appears to be a bug with that where changes are lost

@Simeon No, I am not using that feature (but sweet feature, btw!). I’m sorry to make you have to guess what I’m doing. I’ll figure out exactly what I’m doing that causes this to happen - hopefully later this evening.

I’m losing code also, just by tapping code, run it, and Codea crash.
When I reopen the project, it has returned to it’s preview save. My solution is to close and reopen the project before each run. -_-

Hi All,
Could you all post your iOS and Codea versions when you post (like @dave1707), it helps narrow down the problems and helps @Simeon et al focus on the right code. Or, you could fill those details in your profile and update when necessary.

I’m on iOS 13.1 and Codea 3.0.1 (187).

@Simeon , what is happening to @moechofe2 is what I am experiencing. I thought it happened in another case too, but at least once I definitely had the same sequence of events he had. 3.0 (187)

@brianolive @moechofe2

So the process is

  1. Run code
  2. Codea crashes (code doesn’t run)
  3. Re-open Codea and notice that last edits are not saved in the file

But I’m guessing (2) doesn’t happen consistently?

There is a hidden feature that might help you work around this while I debug the issue:

  1. Long press the play button in the top right corner
  2. A dialog will pop up asking to save your project prior to running it
  3. Choose “Save & Run”

Long press play - nice! Great to know.

Step 2 is not a problem on your end - it is not consistent. That (usually) only happens when something is wrong with my code that makes Codea/Lua unhappy…

The loss of state after that crash is the issue.

I have also seen this code loss happen though without an app crash. I’ll return to the code editor, maybe make some code changes, run my code again, and then notice that the program is still executing from the previous version of my code (i.e. how the code was before my most recent edits). I’ll think to myself (for example), “How can that be? I just commented those lines out”, or something like that…then return to the editor, only to see that the changes I made (commenting out lines, adding new lines, etc.) are gone. Codea was running the code from a state before my last changes.

IOS 12.4.1
Codea 3.0 (187)
I’m using iCloud as document storage from the setting app.

@Simeon the steps are exactly as you describes.

I will be aware the next it crash and trying to explain more precisely.

Thanks for the details! I’ll keep looking into this, for now please try using the long-press option

(The reason this isn’t the default behaviour is in case you are editing documents over a network, where the save could take a long time)

@Simeon - may be related. Firstly I have had a few crashes recently with a project that I have been putting together. It involves multiple print() commands and I think memory requirements were probably exceeded.

The issue I would like to raise was after running Codea, I opened the Codea root folder up in the files app. Whilst playing around in the files app looking for a file Codea bombed out. I will try to reproduce - have you altered the file system within Codea in the latest version?

I’d like to add a data point. I’m on the latest published version of Codea on iPadOS. I’ve experienced it where Codea seems to have cached an old version of the code and it runs that rather than any changes. If I exit the editor, run another Codea program, and then return to the original one then the code is the old version and my changes are lost. It is intermittent, but there are no crashes involved.

The long press to reveal a “save” option is fantastic - I was going to request a “force save” option to avoid this issue.

@Bri_G what issue did you find in the file system? I haven’t altered it, inside the Codea folder there is your documents, and any folders with projects are treated as collections in the UI

@LoopSpace thank you for the extra report. Would you say it happens often? I’ll try to track this down

@Simeon - No issue with the file system, Codea was running in the background whilst I was using file app on the Codea folder. A shrinking window.popped up over the file window - an alert to say Codea had bombed. The alert was very brief, so I missed the detail but got the message.

Oh, by the way - thanks for the save then run option, I may use that by default.

@Simeon - just found another issue. After using search and replace, on returning to the editor window, I found several instances of the highlighted search term dotted round my code - in some cases in free space in others overlapping my code.

The issue is elusive, so still no guaranteed way to reproduce it that I’ve found yet, but - in hopes of this hitting @Simeon ’s radar, I wanted to add one more way that this manifests: Today I made a small change (arg value in rect() call), changed Codea tabs, returned to the first tab, and the arg was the older value. My change went away. No code execution between the tab changes.

And also, as an example, here’s an unfortunately typical situation for me since Codea 3.0:
Today I added some logic when a touch is in the BEGAN state. I test by tapping, and nothing. I’ve done this a million times, so I check my code to see if I’ve done anything dumb. Same behavior. Then I add a print statement. Nothing! Then I realize, ok, it’s happening again. I close the project, sometimes close Codea too, and return to my project to find that my tap logic isn’t even there. I have to enter it again.

I don’t believe that long tap saving solves this. I’ll be more consistent with its usage, and see. But - I don’t want to have to do that.