简体   繁体   中英

Delphi IDE weird source code formatting

Sometimes after pressing some keys in Delphi IDE all functions headers become looking like this:

constructor TClient.Create(

  const AServer: TServer;

  const APhone: AnsiString);

It's a little annoying cause the code formatter (CTRL-D) cannot amend such code properly and I have to remove all line breaks manually. How does it happen?

I found how it actually happens and can repeat these formatting results: you format the code with the specific sintax error, correct the code and then format it again. The example is here:

type
  TTableDesc = record
    constructor Create(););
  end;

  function func(const a: string; const b: Boolean; const c: pointer): string;

After the actions I mentioned above you'll get this:

type
  TTableDesc = record
    constructor Create();
  end;

function func(

  const a: string;

  const b: Boolean;

  const c: pointer): string;

The best way to avoid it is just not to format the code with errors.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM