fprettify icon indicating copy to clipboard operation
fprettify copied to clipboard

Indenting line labels

Open blaylockbk opened this issue 3 years ago • 1 comments
trafficstars

I'm using this example from Milan Curcic's book https://github.com/modern-fortran/stock-prices/blob/master/src/mod_io.f90

integer function num_records(filename)
  ! Return the number of records (lines) of a text file.
  character(len=*), intent(in) :: filename
  integer :: fileunit
  open(newunit=fileunit, file=filename)
  num_records = 0
  do
    read(unit=fileunit, fmt=*, end=1)
    num_records = num_records + 1
  end do
  1 continue
  close(unit=fileunit)
end function num_records

When fprettify formats this, the line label is pushed all the way left.

integer function num_records(filepath)
   ! Return the number of records (lines) of a text file.
   character(len=*), intent(in) :: filepath
   integer :: fileunit
   open (newunit=fileunit, file=filepath)
   num_records = 0
   do
      read (unit=fileunit, fmt=*, end=1)
      num_records = num_records + 1
   end do
1  continue                           ! <----- Note this line is dedented
   close (unit=fileunit)
end function num_records

I realize there are legacy reasons for putting the line label in the first column, but this interferes with code folding (VS Code). Is there any possibility of turning this off and letting the line label to be aligned with the rest of the content?

blaylockbk avatar Oct 14 '22 18:10 blaylockbk

This behavior is correct. Although, I am not able to find an official documentation about the label specifier. From my experience, it is a good practice to put label at the first column of a line.

vickysharma0812 avatar Dec 16 '22 16:12 vickysharma0812