gpt4 book ai didi

Delphi 代码完成因匿名方法而失败

转载 作者:行者123 更新时间:2023-12-03 14:52:00 25 4
gpt4 key购买 nike

请创建一个新的 FMX 应用程序,添加一个按钮和一个备忘录来运行此示例。我有这个代码:

procedure TForm1.Button1Click(Sender: TObject);
begin
TTask.Run(procedure
var
client: TIdHTTP;
result: string;
begin
client := TIdHTTP.Create(nil);
try
try
client.ReadTimeout := 4000;
client.ConnectTimeout := 4000;
result := client.Get('a valid url here just as test');
TThread.Synchronize(nil, procedure
begin
Memo1.Lines.Add(result);
end);
except
on E: Exception do
begin
TThread.Synchronize(nil, procedure
begin
Memo1.Lines.Add(E.Message);
end);
end
end;
finally
client.Free;
end;
end);
end;

它按我的预期工作,但问题出在 IDE 中。如果我将光标放在匿名函数主体中的某个位置,我会自动得到finally 语句的结束。

我该如何解决这个问题?

<小时/>

首先我在这里

enter image description here

然后我按 Enter 键,我就得到了这个!

enter image description here

如果将光标放在行首而不是行尾,则可以添加新空格而无需补全。如何解决这个问题呢?嗯,我发现这个问题发生是因为有这样的代码:

TThread.Synchronize(nil, procedure
begin
Memo1.Lines.Add(result);
end);

如果删除此代码,该问题就不会再发生。这是 IDE 中的错误吗?

最佳答案

Is this a bug in the IDE?

是的。这是一个缺陷。请向质量门户提交报告。

关于Delphi 代码完成因匿名方法而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52483218/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com