Delphi自动格式化源码破坏匿名程序 [英] Delphi automatic Format Source corrupts anonymous procedures
问题描述
不过,我发现它破坏了匿名的布局程序。有没有一个设置可以改善这个结果?
例如,如果我有以下代码:
procedure TServerThread.cbUpdateStreamProgBar(Precentage:Integer);
begin
Synchronize(
procedure
begin
FrmMain.StreamProgressBar.StepBy(Precentage);
end);
end;
在自动格式化源代码之后,它按如下方式折叠:
procedure TServerThread.cbUpdateStreamProgBar(Precentage:Integer);
begin
Synchronize(procedure begin FrmMain.StreamProgressBar.StepBy
(Precentage); end);
end;
我怎样才能避免这种情况?
您必须升级到Delphi的更新版本,如注释中所述。
XE2中的自动源格式化程序可以用于匿名方法。
另外,您可以尝试实验GExperts IDE插件。如果格式不正确,可以使用源代码来添加自己的样式。
另请参阅 Delphi代码格式化程序
。
更新,想想看,有一个解决方法。有点乏味,但。
通过选择源文件的一部分,只有选择将被格式化按 ctrl + D 。
Yesterday I discovered the Format Source feature in Delphi, and it saves me a lot of time.
However, I've discovered that it corrupts the layout of anonymous procedures. Is there a setting that can improve this result?
For example, if I have the following code:
procedure TServerThread.cbUpdateStreamProgBar(Precentage: Integer);
begin
Synchronize(
procedure
begin
FrmMain.StreamProgressBar.StepBy(Precentage);
end);
end;
After I auto-format the source code, it is collapsed as follows:
procedure TServerThread.cbUpdateStreamProgBar(Precentage: Integer);
begin
Synchronize( procedure begin FrmMain.StreamProgressBar.StepBy
(Precentage); end);
end;
How can I avoid this?
You have to upgrade to a newer version of Delphi as noted in comments. The automatic source formatter in XE2 is ok for anonymous methods.
As an alternative you can try the Experimental GExperts IDE PlugIn. If it does not format correctly, there is source code to add your own style.
See also Delphi code formatter
.
Update, coming to think about it, there is a workaround. A bit tedious though. By selecting parts of your source, only the selection will be formatted by pressing ctrl+D.
这篇关于Delphi自动格式化源码破坏匿名程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!