Recent

Author Topic: Save fold state  (Read 1568 times)

bigeno

  • Sr. Member
  • ****
  • Posts: 266
Save fold state
« on: May 20, 2022, 09:44:19 am »
I have a problem with saving folding state when closing a project. Sometimes only part of the folds are saved, sometimes not.
From what I noticed if I have a few folds it happens that they are saved when closing the project, but when there are more of them then only the first two/three are saved.
Is there any method to call save fold state manually ?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9793
  • Debugger - SynEdit - and more
    • wiki
Re: Save fold state
« Reply #1 on: May 20, 2022, 12:30:21 pm »
No, there is no method to call it "independently".

But you can do "Save Project" which will include saving the project session, and saving the fold info.
I doubt that it will  help though.

If some folds are not restored, then that indicates a bug => so even if there would be a save-fold and you called it explicitly, then it would do no better.


In order to be able to fix this, I will need steps to reproduce. I.e. a unit in which that happens, and instructions what I need to fold, so that it wont be restored.

bigeno

  • Sr. Member
  • ****
  • Posts: 266
Re: Save fold state
« Reply #2 on: May 20, 2022, 08:58:44 pm »
Thanks for info. I can just open for example "C:\lazarus220\components\synedit\synedit.pp" and fold 6 procedures blocks - attached image (before.png).
I made some nonsignificant changes to bring up the save change window when I close lazarus. I save it.
After restart lazarus and opened my project I see only 2 folds - attached image (after.png).


Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9793
  • Debugger - SynEdit - and more
    • wiki
Re: Save fold state
« Reply #3 on: May 20, 2022, 11:54:16 pm »
I did a quick test (with 2.2.2 and with my trunk install).

And unfortunately it worked for me (in both versions).


Could you do 2 things please.

1) Compile your IDE (Tools > Configure Build Lazarus) with
Code: Text  [Select][+][-]
  1.  -dSynFoldDebug  -dSynFoldSaveDebug -dSynCaretDebug  -dSynDebug -dSynTrimDebug  -dSynAssert  -dSynAssertFold
And start it with  --debug-log=c:\mylog.txt

And then get me the logs. (Plural, one log for saving the session, a 2nd log for loading it)

2)
Once you saved the project (with the SynEdit) exactly as described in your post find the lps and lpi file and send them to me. Copy the file before you open the project again.

The lps may be in the primary config path / or if your setting is to save the session in the project file, then there is no lps file.


---
EDIT: I see you are on 2.2.0
But that should make no diff to 2.2.2 for the described behaviour.
I am not aware of any changes between 2.2.0 and 2.2.2 that could have any effect on this.
« Last Edit: May 21, 2022, 12:03:33 am by Martin_fr »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9793
  • Debugger - SynEdit - and more
    • wiki
Re: Save fold state
« Reply #4 on: May 21, 2022, 12:02:23 am »
One more thing....

Did you rebuild your IDE before?  And if so, did you build it with -O2 or higher optimization? If yes, then please rebuild your IDE with -O1 (and select "clean all"), and see if the problem still happens.

There is (at least) one issue in the FPC optimizer that can cause any sort of faulty behaviour. It is extremely rare to actually happen (I know of only one case ever where it did cause problems). So it is unlikely to be the issue. But one never knows....


bigeno

  • Sr. Member
  • ****
  • Posts: 266
Re: Save fold state
« Reply #5 on: May 21, 2022, 07:06:00 pm »
Hi,
strange but after recompiling the IDE this example works fine. However I found another file where the problem occurred. I have sent the data to you PM.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9793
  • Debugger - SynEdit - and more
    • wiki
Re: Save fold state
« Reply #6 on: May 21, 2022, 08:06:47 pm »
Ok, that example I can reproduce. (with 2.2.2 AND 2.3)
And the error log also shows that it had problem reading the data.

It might take a little while before I can debug it. Currently got some other tasks that need to be done first.

bigeno

  • Sr. Member
  • ****
  • Posts: 266
Re: Save fold state
« Reply #7 on: May 21, 2022, 10:30:39 pm »
thanks, good that you can reproduce.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9793
  • Debugger - SynEdit - and more
    • wiki
Re: Save fold state
« Reply #8 on: June 25, 2022, 10:22:15 pm »
Took a while, but I eventually got to it. As for as I can test it should be fixed.
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/339ede7382ab19d68df5f88509253de4d443df53

You only need the changes to components/synedit/syneditfoldedview.pp
The other files are the testcase.

You only need to amend a few lines, and recompile your IDE.

bigeno

  • Sr. Member
  • ****
  • Posts: 266
Re: Save fold state
« Reply #9 on: June 26, 2022, 12:05:00 pm »
NICE it works!!!
it's important improvement for me, Thanks!!

 

TinyPortal © 2005-2018