* * *

Author Topic: [SOLVED] Control-D no confirmation option to JCF formatting  (Read 1743 times)

tudi_x

  • Sr. Member
  • ****
  • Posts: 400
hi All,
please advise if there is an option not to have displayed the confirmation option for the JCF formatting?

thank you
« Last Edit: July 12, 2017, 12:28:19 pm by tudi_x »

GetMem

  • Hero Member
  • *****
  • Posts: 2465
Re: Control-D no confirmation option to JCF formatting
« Reply #1 on: July 12, 2017, 12:20:18 pm »
Hi tudi_x,

I don't see any option to disable that dialog, however if you go to $(LazarusDir)\components\jcf2\IdePlugin\lazarus\jcfidemain.pas and comment out the line in the see screenshot, then reinstall package $(LazarusDir)\components\jcf2\IdePlugin\lazarus\jcfidelazarus.lpk, the dialog won't appear again. Ideally we should add an checkbox to Options-->Editor-->JCF Format Settings:  "Show confirmation dialog?", checked by default. I'm too lazy for that now.  :-[

tudi_x

  • Sr. Member
  • ****
  • Posts: 400
Re: Control-D no confirmation option to JCF formatting
« Reply #2 on: July 12, 2017, 12:27:44 pm »
thank you for the hint GetMem.

no hurry, Lazarus is still the best IDE. :)

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3262
  • I like bugs.
Re: Control-D no confirmation option to JCF formatting
« Reply #3 on: July 12, 2017, 01:07:15 pm »
no hurry, Lazarus is still the best IDE. :)
Please provide a patch.
There is also another thread regarding JCF:
 http://forum.lazarus.freepascal.org/index.php/topic,37518
Many people agree that the GUI should be changed but nobody promised to do it.

GetMem

  • Hero Member
  • *****
  • Posts: 2465
Re: [SOLVED] Control-D no confirmation option to JCF formatting
« Reply #4 on: July 12, 2017, 03:37:58 pm »
@Juha

Patch attached. Please apply, I don't have commit rights in that folder.
« Last Edit: July 12, 2017, 03:54:42 pm by GetMem »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3262
  • I like bugs.
Re: [SOLVED] Control-D no confirmation option to JCF formatting
« Reply #5 on: July 12, 2017, 05:12:14 pm »
Q: What is the idea here in unit ConvertTypes:
-  OLD_REG_ROOT_KEY = '\Software\Jedi\JediCodeFormat';
+  OLD_REG_ROOT_KEY = 'Software\Jedi\JediCodeFormat';

Was there a bug in the registry path?

GetMem

  • Hero Member
  • *****
  • Posts: 2465
Re: [SOLVED] Control-D no confirmation option to JCF formatting
« Reply #6 on: July 12, 2017, 06:16:29 pm »
@Juha
Quote
Was there a bug in the registry path?
Yes. If you put the slash back, Lazarus throws an exception: "Failed to create key ''\\Software\Jedi\JediCodeFormat". Please note the double backslash in the front.
« Last Edit: July 12, 2017, 06:31:17 pm by GetMem »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3262
  • I like bugs.
Re: [SOLVED] Control-D no confirmation option to JCF formatting
« Reply #7 on: July 12, 2017, 06:52:25 pm »
Yes. If you put the slash back, Lazarus throws an exception: "Failed to create key ''\\Software\Jedi\JediCodeFormat". Please note the double backslash in the front.
I applied the patch in r55491. Thanks.
I wonder why nobody noticed the bug earlier.

GetMem

  • Hero Member
  • *****
  • Posts: 2465
Re: [SOLVED] Control-D no confirmation option to JCF formatting
« Reply #8 on: July 12, 2017, 07:03:55 pm »
Quote
I wonder why nobody noticed the bug earlier.
Because the frame frFiles.pas(Options-->JCF Format Settings-->Format File) did not attempt to write back anything to registry, basically it was read only until know. Take a look at WriteSettings method, before the patch it looked like this:
Code: Pascal  [Select]
  1. procedure TfFiles.WriteSettings(AOptions: TAbstractIDEOptions);
  2. begin
  3.   FormatSettings.Description := mDescription.Text;
  4. end;
Where FormatSettings is the TFormatSettings(https://www.freepascal.org/docs-html/rtl/sysutils/tformatsettings.html) it has nothing to do with JEDI format settings/registry.

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3262
  • I like bugs.
Re: [SOLVED] Control-D no confirmation option to JCF formatting
« Reply #9 on: July 13, 2017, 11:24:07 am »
Where FormatSettings is the TFormatSettings(https://www.freepascal.org/docs-html/rtl/sysutils/tformatsettings.html) it has nothing to do with JEDI format settings/registry.
Sorry but your diagnosis is wrong. For some reason JEDI named their options class as "TFormatSettings" and a function "FormatSettings". It is extremely confusing especially because the same unit frFiles also uses DefaultFormatSettings from Sysutils.
It must be changed ... and so I did in r55493. It is now "FormattingSettings".

In my tests the new option is not persistent. I turn it off, then restart Lazarus and it is on again.
Restoring the backslash to OLD_REG_ROOT_KEY makes no difference. No errors but still not persistent.
Tested in Linux. The code uses TRegIniFile which is cross-platform.
IMO this looks wrong without backslash:
  OLD_REG_ROOT_KEY = 'Software\Jedi\JediCodeFormat';
Every other registry path has the leading backslash.

The package has JcfSettings which uses JcfRegistrySettings. It is not straightforward.
Can you please take a look.

GetMem

  • Hero Member
  • *****
  • Posts: 2465
Re: [SOLVED] Control-D no confirmation option to JCF formatting
« Reply #10 on: July 13, 2017, 04:36:32 pm »
Quote
Sorry but your diagnosis is wrong. For some reason JEDI named their options class as "TFormatSettings" and a function "FormatSettings". It is extremely confusing especially because the same unit frFiles also uses DefaultFormatSettings from Sysutils.
It must be changed ... and so I did in r55493. It is now "FormattingSettings".
What a mess! I even [Ctrl] + [Click]-ed the old FormatSettings(now FormattingSettings) and took me to Sysutils. How is this possible? TJCFRegistrySettings(JcfRegistrySettings.pas) combined with OLD_REG_ROOT_KEY = '\Software\Jedi\JediCodeFormat' is not working at all, however it works under windows with OLD_REG_ROOT_KEY = 'Software\Jedi\JediCodeFormat' and writes the data to the registry. Unfortunately this is not good enough because it's not cross-platform.
If I move the checkbox and its setting to TFormattingSettings(JcfSettings.pas) it works both under windows, linux and osx, even when OLD_REG_ROOT_KEY = '\Software\Jedi\JediCodeFormat', and writes data to file. Please test attached patch. Thank you!
« Last Edit: July 14, 2017, 05:19:54 am by GetMem »

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3262
  • I like bugs.
Re: [SOLVED] Control-D no confirmation option to JCF formatting
« Reply #11 on: July 13, 2017, 09:29:50 pm »
What a mess! I even [Ctrl] + [Click]-ed the old FormatSettings(now FormattingSettings) and took me to Sysutils. How this is possible?
It is apparently a bug in Codetools but it does not happen always.
I first Ctrl-Clicked FormatSettings.Description and it went to the correct place. Then I jumped to DefaultFormatSettings, came back, and Codetools started to behave bad.
Somebody should make a simple demo where the issue can be reproduced and then report in bug tracker.

Quote
Please test attached patch. Thank you!
Applied in r55497. Works now. :)

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus