View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0038543||Lazarus||IDE||public||2021-02-25 10:01||2021-02-27 08:56|
|Product Version||2.1 (SVN)|
|Summary||0038543: JCF Extra spaces|
|Description||For this code:|
if True then Exit;
If I add two or more space after then, after reformat, JCF makes them two space, but if I add just one space, it will keep it as one.
Almost the same thing happens for this:
with Self do;
This time JCF keeps two space before Self if I write more than one space. This will not happen for spaces after Self or after do.
I do not know about other cases, but I think it can be good to do make it more coordinated.
In the "Steps To Reproduce" is the test code, try reformatting it to see extra spaces. Then try to remove them and reformat again. It seems JCF chooses one or two spaces, if this is a need, it should be an option for it and I could not find one existing.
|Steps To Reproduce|| if True then Exit;|
with Self do Exit;
|Tags||No tags attached.|
|Fixed in Revision|
||JCF Format Settings - Clarify - Spaces - Max spaces in code|
Yes but JCF does not keep this option all the time. For example the "Max spaces in code" default value is set to 2 for me.
In the example, It will reduce space count before "Self" to two, but for after of "Self" it will reduce spaces to one anyway.
Please check the sample for more clarification.
It works as designed, JCF only permits one space before or after some tokens.
"then" and "do" are part of those tokens.
> with Self do Exit;
>but for after of "Self" it will reduce spaces to one anyway.
is not after "Self", is before "do" so only allows one space.
I think that no changes are required.
The tokens are:
SingleSpaceAfterTokens: TTokenTypeSet = [ttColon, ttAssign, ttComma,
ttPlusAssign, ttMinusAssign, ttTimesAssign, ttFloatDivAssign];
SingleSpaceAfterWords: TTokenTypeSet = [ ttProcedure, ttFunction,
ttConstructor, ttDestructor, ttProperty,
ttOf, ttDo, ttWhile, ttUntil, ttCase, ttIf, ttTo, ttDownTo, ttGeneric];
SingleSpaceBeforeWords: TTokenTypeSet = [ttEquals, ttThen, ttOf, ttDo,
NoSpaceAfterTokens: TTokenTypeSet = [ttOpenBracket, ttOpenSquareBracket];
> It works as designed, JCF only permits one space before or after some tokens.
Any info on why it is working that way? It seems disordered.
I think formatter should act alike no matter developer typed one or two spaces by mistake.