Jump to content
Sign in to follow this  
dummzeuch

How should spaces after a comment be handled by the formatter

Recommended Posts

Posted (edited)

There are currently some unit tests for the GExperts code formatter that fail.

It all depends on how spaces after comments {comment} or (*comment*) are handled.

 

A How should the code formatter handle the following code:

procedure bla;
begin
  {some comment} SomeStatement;
end;

A1 Keep the space after the comment:

procedure bla;
begin
  {some comment} SomeStatement;
end;

A2 Remove the space after the comment:

procedure bla;
begin
  {some comment}SomeStatement;
end;

 

B what about this code:

procedure bla;
begin
  {some comment}SomeStatement;
end;

B1 should the formatter leave it as is?

B2 should it insert a space, so it gets changed into:

procedure bla;
begin
  {some comment} SomeStatement;
end;

 

C what about this code with multiple spaces after the comment:

procedure bla;
begin
  {some comment}     SomeStatement;
end;

C1 should the formatter remove the spaces:

procedure bla;
begin
  {some comment}SomeStatement;
end;

C2 or should it reduce them to one space:

procedure bla;
begin
  {some comment} SomeStatement;
end;

C3 or should it leave them as them as they are:

procedure bla;
begin
  {some comment}     SomeStatement;
end;

 

The current code will always remove the spaces, so its A2, B1 and C1.

 

I'm tending towards keeping the number of spaces as they are, that would be A1, B1 and C3.

 

I'm definitely not going to make this configurable. I wouldn't even know how to describe this configuration option.

Edited by dummzeuch

Share this post


Link to post
Posted (edited)
13 minutes ago, dummzeuch said:

I wouldn't even know how to describe this configuration option.

why not?

image.thumb.png.4ecdbe2ecbb0ded8705b5cdac32d6fb5.png

 

 

you could name it "The option I didn't want to implement #4223"

 

 

Edited by Attila Kovacs
  • Like 1

Share this post


Link to post

I would also prefer a setting:

1. No space

2. Space

3. Line break

4. leave untouched

 

I personally would prefer the "1 space" variant, but I would also not want to have a comment on the left of a statement.

I would prefer the comment above or on the right.

Edited by baka0815

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×