editor problems lazarus / 61-Beginners ---------------------------------------------------------------------- JLWest · 2019-04-13 04:55 Has anyone experienced the IDE and /or compiler misplacing source code. I compiled and half of a procedure was placed under the type definitions. This is the second time  in a week this has occurred. Just wondering ---------------------------------------------------------------------- Handoko · 2019-04-13 05:59 No, I haven't. The IDE and compiler are working good. Please provide more information and step-by-step how to do it. ---------------------------------------------------------------------- JLWest · 2019-04-13 06:45 I might have a stepbystep as I quit the program. I might be able to reproduce the problem. Attached is a copy of the scrambled code: Starting a line 67 there is part of  a procedure that was down in the program. ---------------------------------------------------------------------- Birger52 · 2019-04-13 08:43 Have no problems -on a stationary PC. On a portable, watch sleeves on musepad... Happens to me often. ---------------------------------------------------------------------- jamie · 2019-04-13 13:21 I've never seen that happen here. Maybe you are using function keys a lot instead of menus and could be hitting the copy paste, inserts by accident using the F9 key for run or other keys..  There could be a key board issue but I have my hands on the mouse most of the time and use menus.. ---------------------------------------------------------------------- Martin_fr · 2019-04-13 13:46 Never seen or heard of... Is/Was the file open in the editor all the time? (IDE not closed, file in editor)? Does the IDE prompt you do reload the file (changed on disk)? Or is the file suddenly modified inside the IDE? Any packages installed into the IDE? Run checkdisk? Happens with any file? (Project or packages or even lcl, rtl)? Open files only, or closed files too (since you mentioned compiler) If not any file, files from diff projects? Or just very specific files? Or just if specific files appear somewhere in the uses clauses? --- If the file is open in the editor, then try to use undo/redo to identify at what time the change happened (hoping that it is in the undo buffer). What other changes were made just before (or a couple of steps before)? Any pattern (if you re-trace this on several occasions) -- Compile your IDE with  -gh -Criot -gt  -Sa  -O-1 Add the following defines  -d.... CheckNodeTool VerboseUpdateNeeded SynCheckPaintLock SynClipboardExceptions AssertSynMemIndex SynAssert SynAssertFold Add  -WC   to get a console window, and be able to watch the IDE log output. (rebuild your startlazarus accordingly too) ---------------------------------------------------------------------- JLWest · 2019-04-13 19:20 Quote from: Birger52 on April 13, 2019, 10:43:03 amHave no problems -on a stationary PC. On a portable, watch sleeves on musepad... Happens to me often. Sorry I don't understand this? oh, mousepad and the sleeves. Mo I'm on a deskto and regular keyboard. ---------------------------------------------------------------------- JLWest · 2019-04-13 19:21 Quote from: jamie on April 13, 2019, 03:21:20 pmI've never seen that happen here. Maybe you are using function keys a lot instead of menus and could be hitting the copy paste, inserts by accident using the F9 key for run or other keys..  There could be a key board issue but I have my hands on the mouse most of the time and use menus.. Seldom if ever use the F Keys. ---------------------------------------------------------------------- JLWest · 2019-04-13 19:41 Quote from: Martin_fr on April 13, 2019, 03:46:02 pmNever seen or heard of... Is/Was the file open in the editor all the time? (IDE not closed, file in editor)? I believe so. Does the IDE prompt you do reload the file (changed on disk)? Or is the file suddenly modified inside the IDE? No. Any packages installed into the IDE? No Run checkdisk? OK - No Errors Found Happens with any file? (Project or packages or even lcl, rtl)? Open files only, or closed files too (since you mentioned compiler)  Say what? If not any file, files from diff projects? Or just very specific files? Or just if specific files appear somewhere in the uses clauses? Don't understand that. --- If the file is open in the editor, then try to use undo/redo to identify at what time the change happened (hoping that it is in the undo buffer). What other changes were made just before (or a couple of steps before)? Any pattern (if you re-trace this on several occasions) Maybe late for undo. -- Can you give a little more detail on the following, please. Compile your IDE with  -gh -Criot -gt  -Sa  -O-1      I have never compiled the IDE. Installed the IDE and FPC with no changes as I remember a couple of years ago. Add the following defines  -d.... CheckNodeTool VerboseUpdateNeeded SynCheckPaintLock SynClipboardExceptions AssertSynMemIndex SynAssert SynAssertFold Add  -WC   to get a console window, and be able to watch the IDE log output. (rebuild your startlazarus accordingly too) Where do I add a -WC Here is how I think it happened. I finished writing a program with no problems. I wanted to start a new program that used a lot of the controls and functions of the finished program. Created a new Sub Dir. Copied the finished program to the new sub dir. Opened the copied program in the new sub dir. Deleted a bunch of controls. Compiled using the Run>Build to see what I needed to delete in the code editor. That's when I think it happened. . ---------------------------------------------------------------------- Martin_fr · 2019-04-13 20:21 It helps, if you close the quote before your reply, and re-open it after... Use the preview button to check if you got them right. QuoteQuoteHappens with any file? (Project or packages or even lcl, rtl)? Open files only, or closed files too (since you mentioned compiler) Say what? QuoteIf not any file, files from diff projects? Or just very specific files? Or just if specific files appear somewhere in the uses clauses? I assumed it happened on a regular base to you (reading further in your last reply, it seems it was a one off?). If it were regular, the question would be, if it always affected the same unit (or a small amount of units)? Or if it randomly affected any unit (either open in editor, or on your disk) I guess the answer is, it affected one unit only, since it happened just once? QuoteQuoteCompile your IDE with -gh -Criot -gt  -Sa  -O-1    I have never compiled the IDE. Installed the IDE and FPC with no changes as I remember a couple of years ago. In the Tools menu is an entry "Configure build Lazarus" It has a field (memo) "Options" where you enter the above settings. In this field you also put the -WC As for the "Add the following defines": You can press the button "Edit defines" and insert them (one per line / copy and paste). Then the will show in the "Defines" box, and you can set the checkboxes. Press "Build" to rebuild your IDE. QuoteHere is how I think it happened. I finished writing a program with no problems. I wanted to start a new program that used a lot of the controls and functions of the finished program. Created a new Sub Dir. Copied the finished program to the new sub dir. Opened the copied program in the new sub dir. Deleted a bunch of controls. Compiled using the Run>Build to see what I needed to delete in the code editor. That's when I think it happened. Best way to copy a project is to (project menu): Publish project. This way you avoid that there are any reference between the old and new project. But that is not necessarily related to the issue. Your steps should have worked too. The IDE internally hold a 2nd buffer of the code, for codetools to work with. (menu: view > Ide internals > show codetool nodeinfo) I have never had any issue like it, but it is possible that that copy became out of sync, and was written back. Should it happen again, immediately go to this menu, choose the unit that is in question, copy all info into an editor outside the IDE and save it. Also make a backup of the corrupt file on disk, and copy/paste the editor content to a new file. Then (after that) see if undo reveals anything. ---------------------------------------------------------------------- JLWest · 2019-04-13 21:29 Actually it has happened twice recently but the first time was a small line of code placeed above the Implementations clause.  It was easily fixed. I hesitate to report any of this prior to an earlier incident where I thought the compiler was scrambling code. It turned out It was something I was doing in the editor. And I'm sure in this case it's probably something I'm doing. I'll fool around with publish. Thanks for the directions. ---------------------------------------------------------------------- Martin_fr · 2019-04-13 22:00 Another idea, maybe you accidentally recorded some input as macro and replayed it? shift-ctrl R  to start/stop Recording shift-ctrl P  to rePlay it ---------------------------------------------------------------------- JLWest · 2019-04-14 00:27 I sometimes run my program with  Shft Ctl F9 but usually Run>Build and in the process of developing I will create a shortcut to the .EXE and just use that. I couldn't reproduce the issue. Started a whole new project and I'm liking it better than the copy idea. I haven't recompiled the IDE. as suggested Wondering what that would do vs the risk of screwing it up. But Thanks for you help.