jedi issue with align and if..then..else lazarus / 9-Editor ---------------------------------------------------------------------- glubbish · 2020-08-12 22:33 To reproduce: create new project create onactivate for form1 I have not been able to find good documentation for the jcf settings. If anyone knows what to change to fix this, that would be great. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormActivate(Sender: TObject);var  s: string;begin  Top        := (screen.Height - Height) div 2;  Left := (screen.Width - Width) div 2;  if Top < 400 then s:= 'small' else s:='big';  Top  := (screen.Height - Height) div 2;  Left   := (screen.Width - Width) div 2;end;   ; format with ctrl-d gives: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormActivate(Sender: TObject);var  s: string;begin  Top  := (screen.Height - Height) div 2;  Left := (screen.Width - Width) div 2;  if Top < 400 then s                   := 'small' else s := 'big';  //actual problem  Top := (screen.Height - Height) div 2;                           //this does not align like the same lines before the if.  Left := (screen.Width - Width) div 2;end; jcfsettings attached. ---------------------------------------------------------------------- Fred vS · 2020-08-12 22:39 Hello. There are some problems with jedi code beautifier. You may try ptop, it is part of fpc project, I get better result with it. Fre;D ---------------------------------------------------------------------- ASerge · 2020-08-13 19:30 Quote from: glubbish on August 13, 2020, 12:33:33 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormActivate(Sender: TObject);...end;   ; format with ctrl-d gives: I have in case of the presence of that extra semicolon Jedi Code Format does not work at all. But if remove extra semicolon, it gives out: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormActivate(Sender: TObject);var  s: string;begin  Top := (screen.Height - Height) div 2;  Left := (screen.Width - Width) div 2;  if Top < 400 then    s := 'small'  else    s := 'big';  Top := (screen.Height - Height) div 2;  Left := (screen.Width - Width) div 2;end; ---------------------------------------------------------------------- glubbish · 2020-08-13 22:25 @Fred - I would prefer the in ide formatter. A command line one is very cumbersome. @ASerge - The extra semicolon was a copy/paste error. My testcase does not have it either. I want it to format simple if.then.else on a single line and only break when begin is used eg: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i           if Result = 0 then          begin            prefix  := 'Updated';          prefix2 := 'Updating: ';          end          else          begin            prefix  := 'Copied';            prefix2 := 'Copying: ';          end;If you use my settings.jcf (uploaded) you should get the same results. ---------------------------------------------------------------------- Fred vS · 2020-08-13 23:03 Quote from: glubbish on August 14, 2020, 12:25:21 am@Fred - I would prefer the in ide formatter. A command line one is very cumbersome. Indeed strange that Lazarus did not integrate Ptop in his IDE. Fre;D ---------------------------------------------------------------------- ASerge · 2020-08-14 13:15 Quote from: glubbish on August 14, 2020, 12:25:21 amI want it to format simple if.then.else on a single line and only break when begin is used eg: With your jcfsettings.cfg I have the same extra indent. But in my opinion, if.then.else on a single line is a very bad style. ---------------------------------------------------------------------- glubbish · 2020-08-14 23:59 Quote if.then.else on a single line is a very bad style. Horses for courses I guess. I also like single line if.then. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  if Count = 2 then Result := True; As to the problem. If you set align.max variance to 19, problem does not occur. Setting to 20 or higher it does. ---------------------------------------------------------------------- Paolo · 2020-10-05 13:55 Hi glubbish, maube you already know, but if you like coincise code in just one line if Count = 2 then Result := True; you can do that Result:=(Cont = 2); ---------------------------------------------------------------------- bd4kc · 2020-12-17 21:22 jedi code formatting, I'm not used to writing multiple statements in a single line. Jedi separates them all, causing them to turn pages frequently while reading. I'm looking for a way to separate the extra- long code, I've debugged the confirmed parts, I don't want to see them anymore, but I don't want them to be folded up. How did you do that? ---------------------------------------------------------------------- Zoran · 2020-12-17 23:36 Quote from: Paolo on October 05, 2020, 03:55:40 pmHi glubbish, maube you already know, but if you like coincise code in just one line if Count = 2 then Result := True; you can do that Result:=(Count = 2); No, wrong. No! This would get the same behaviour: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Result := Result or (Cont = 2)Still, not really relevant to the question, which is about code formatting. ---------------------------------------------------------------------- howardpc · 2020-12-18 06:36 Quote from: Zoran on December 18, 2020, 12:36:07 amQuote from: Paolo on October 05, 2020, 03:55:40 pmHi glubbish, maube you already know, but if you like coincise code in just one line if Count = 2 then Result := True; you can do that Result:=(Count = 2); No, wrong. No! This would get the same behaviour: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Result := Result or (Cont = 2)Still, not really relevant to the question, which is about code formatting. Unfortunately you are incorrect.     Result := Result or (count = 2); does not always give the same outcome or behaviour as     Result := count = 2; If Result is initially True, then your OR expression yields True, but the simple comparison yields False, when count <> 2. ---------------------------------------------------------------------- rvk · 2020-12-18 08:26 Quote from: howardpc on December 18, 2020, 07:36:49 amQuote from: Zoran on December 18, 2020, 12:36:07 amQuote from: Paolo on October 05, 2020, 03:55:40 pmHi glubbish, maube you already know, but if you like coincise code in just one line if Count = 2 then Result := True; you can do that Result:=(Count = 2); No, wrong. No! This would get the same behaviour: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Result := Result or (Cont = 2)Still, not really relevant to the question, which is about code formatting. Unfortunately you are incorrect.     Result := Result or (count = 2); does not always give the same outcome or behaviour as     Result := count = 2; If Result is initially True, then your OR expression yields True, but the simple comparison yields False, when count <> 2. That's not what he said. He said Result := Result or (count = 2); Is the same as if Count = 2 then Result := True; Which is correct. It was a reaction to the incorrect answer that Result := count = 2; is the same as if Count = 2 then Result := True; ---------------------------------------------------------------------- Zoran · 2020-12-18 10:00 Yes, thanks RVK. Howard, you missed my point. ---------------------------------------------------------------------- lucamar · 2020-12-18 10:08 Quote from: howardpc on December 18, 2020, 07:36:49 amUnfortunately you are incorrect.     Result := Result or (count = 2); does not always give the same outcome or behaviour as     Result := count = 2; If Result is initially True, then your OR expression yields True, but the simple comparison yields False, when count <> 2. The point is that to replace the "if", Result must not be changed unless Count = 2, so the OR expression is the way to go: when Count <> 2, Result keeps its value and when Count = 2 it changes to True whatever it previously was. ---------------------------------------------------------------------- howardpc · 2020-12-18 11:05 @Zoran Apologies that I missed your (valid) point. ---------------------------------------------------------------------- Zoran · 2020-12-18 11:18 Quote from: howardpc on December 18, 2020, 12:05:45 pm@Zoran Apologies that I missed your (valid) point. I should have been more precise, as later posters were (including you, you actually said exactly what I meant, only you thought that I had meant something else). ---------------------------------------------------------------------- lucamar · 2020-12-18 14:32 You know, I think this kind of misunderstandings are actually quite useful (and funny, to be honest) because they force one to stop and really think about the consequences of things we usually do almost by rote without giving them more than a passing thought. It's quite a (re)learning experience