TAdvMemo / TDBAdvMemo - Parameter Hint causes severe editor lag during cursor movement

When the OnGetParameterHint event returns a non-empty AParameterHint string and the parameter hint popup is visible, cursor movement inside parentheses becomes extremely slow (arrow keys, typing).

Steps to reproduce:

  1. Set AutoHintParameterPosition = hpBelowCode
  2. Implement OnGetParameterHint with Handled := True and return a valid hint string
  3. Type a function call, e.g. MyFunction(param1, param2, param3)
  4. Move the cursor inside the parentheses using arrow keys

Expected: Smooth cursor navigation, same as without hint popup
Actual: Noticeable lag on every keystroke/cursor move. The event fires on every single cursor position change, and each call triggers a full popup repaint.

Analysis:
Even with a trivially fast handler (single cached string comparison, no computation), the lag persists. Setting AParameterHint := '' (no popup shown) makes the editor fast again, confirming the popup rendering is the bottleneck — not the event handler itself.

Environment: TDBAdvMemo, Delphi 13 (Athens), Win32, TMS Component Pack 12.x

Suggestion: Consider skipping the popup repaint when the hint text has not changed since the last call, or throttle the repaint frequency internally.

Additional issue: The parameter hint popup disappears when the cursor is positioned after an opening parenthesis inside a string parameter.

Steps to reproduce:

  1. Have a function with parameter hint: MyFunction(p1:string; p2:integer; p3:string)
  2. Type: MyFunction('some text(', 123, 'other')
  3. Move the cursor inside the string literal after the ( character

Expected: The parameter hint popup remains visible, since the ( is inside a string literal and not a function call Actual: The hint popup disappears because the component interprets the ( as a new function call context, without considering string literal boundaries

Is it slow processing in your OnGetParameterHint() handler that might be causing this?
We retested this here with the code:

procedure TForm1.AdvMemo1GetParameterHint(Sender: TObject; AToken: string;
  var AParameterHint: string; var Handled: Boolean);
begin
  AParameterHint := 'var i: integer;var j: integer;var s: string';
  Handled := true;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  AdvMemo1.AutoHintParameterPosition := hpBelowCode;
  AdvMemo1.Lines.Add('procedure Test(param1,param2,param3);');
end;

but could not notice slowness?

advmemoparamhint

Good morning Bruno,

I have registered the full signature of a procedure/function in Autocomplete, for example:

function mytestfunction(vparam1: string; vP2: integer; vparam3: string): integer;

Later in the editor, I write/use it like this:

result := mytestfunction('1111111aaaa', 10, 'bbbbb(22222');

Two issues can be observed:

  1. When moving the cursor inside the parameter brackets, the editor becomes noticeably slow.

  2. If the cursor is moved within the parameters (e.g. around the second parameter), the parameter hint disappears after the opening parenthesis.

  3. possible that the slowness has to do with too much added entries in the autocomplete list? (i have >300 entries)

  1. I could not see a speed problem here. I add 300 different functions to the HintParameter.Parameters list and see no influence on speed.

Code used:

var
  i: integer;
  s: string;
begin
  for i := 1 to 300 do
  begin
    s := 'mytest' + i.Tostring+ 'function(vparam1: string; vP2: integer; vparam3: string): integer;';
    advpascalmemostyler1.HintParameter.Parameters.Add(s);
  end;
end;

advmemoparamhint2

  1. We could see an issue with string parameters that contain a specific symbol and have applied a fix that will be included in the next release.

  2. See 1)

Crazy, on my side it doesn’t work…
Which screen recording tool are you using? I’d like to use the same one to create a video and show you the bug on our side.

but I can't help but thinking there are other things involved in your application that cause this slowness, so it might be better to try to isolate this and send a sample source project with which we can reproduce the problem here.

I will try to analize as much as possible. What I additional see is a connected tAdvPascalMemoStyler with Hintparameter.parameters containing a lot of elements.

As you can see in my test code, that is exactly what I did. I did add 300 functions to TAdvPascalMemoStyler.HintParameters

Crazy but on my side it is very slow only to move the cursor with arrow keys:

autocompleteproblems

Please isolate and send a sample source project to reproduce

Ticket can be closed – switched to SynEdit, no issues anymore.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.