Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-07

Is there a bug in auto indentation in 1.4 or is it just me?

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bernd

if I write the following code:

procedure foo;
begin
  if true then
  begin
    X
  end
  else
  begin
      X
  end;
end;

The "x" marks the place where it puts my cursor after hitting enter. After the the if then begin it will correctly place me 2 spaces indented relative to the begin, but after the end else begin it will place me 4 spaces relative to the begin.

I cannot find any way to influence this behavior in the editor settings (which are very confusing btw), I cannot even change anything at all there, even if I set everything to 4 spaces instead of 2 it will still use 2 spaces everywhere (and 4 in an else begin branch).

Is this just me or is this a bug in the 1.4 release?

Bernd

Reply by email

Martin Frb
to Bernd
Bernd wrote 8 lines
I cannot find any way to influence this behavior in the editor settings (which are very confusing btw), I cannot even change anything at all there, even if I set everything to 4 spaces instead of 2 it will still use 2 spaces everywhere (and 4 in an else begin branch). Is this just me or is this a bug in the 1.4 release?

You probably have "smart indent" on (see codetools section of config). The editor section has a link that takes you there too.

afaik the smart indent takes it rules from a sample source in the config path...

Reply by email

Bernd
to Martin Frb

Ok, I have a working minimal example, see the attached file.

It seems to be related to the setting: "context sensitive"

In my above example I have two functions "foo" and "bar". The first one is formatted like K+R-Style (begin on end of line), I have been doing this with all my code since the early days already without problems, the only times I am using traditional formatting is when I am working on someone elses project with different formatting. The second function uses the traditional Pascal formatting (begin on own line).

* It only ever seems to affect the else branch of an if, no other constructs I have found to be affected.

In the first function it will still work, it seems when it is trying to figure out the formatting it is looking at the second function (which is formattet like the standard pascal formatting). But as soon as there is more than one else with K+R formatting in the file it will stop working correctly.

* Even if my entire file is formatted strictly K+R it won't be able to indent the else branch correctly anymore, but all other constructs seem to work just fine with this formatting style.
* If I turn "context sensitive" OFF then all problems disappear (even with mixed traditional and K+R formatting).
* If I use an entirely K+R formatted laz_indentation file it makes no difference, it still always works (even for mixed sources).
* If context sensitive is ON it will stop working, regardless of the formatting of the laz_indentation file, even if there is NO (!) laz_indentation file at all, the else branch will always be broken in K+R, all other constructs will be working fine.

Bernd

2015-07-08 15:22 GMT+02:00 Martin Frb :

Show quoted text 22 lines
On 08/07/2015 10:51, Bernd wrote: > > > I cannot find any way to influence this behavior in the editor > settings (which are very confusing btw), I cannot even change anything > at all there, even if I set everything to 4 spaces instead of 2 it > will still use 2 spaces everywhere (and 4 in an else begin branch). > > Is this just me or is this a bug in the 1.4 release? > You probably have "smart indent" on (see codetools section of config). The editor section has a link that takes you there too. afaik the smart indent takes it rules from a sample source in the config path... -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
A non-text attachment was scrubbed...
Name: Unit1.pas
Type: application/octet-stream
Size: 320 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150709/4897ba61/attachment-0001.obj>

Reply by email