fix #9 - highlighting of argument in calltips does not work in auto functions

This commit is contained in:
Basile Burg 2020-03-11 12:36:34 +01:00
parent b81cb2a992
commit 9f22e42fff
1 changed files with 14 additions and 2 deletions

View File

@ -543,7 +543,8 @@ var
r: TStringRange = (ptr:nil; pos:0; len: 0); r: TStringRange = (ptr:nil; pos:0; len: 0);
t: TStringRange; t: TStringRange;
u: TStringRange; u: TStringRange;
j: integer = 0; label
FIXED_AUTO;
procedure writePart(const part: string; var x: integer); procedure writePart(const part: string; var x: integer);
begin begin
@ -563,13 +564,15 @@ begin
b := u.nextLine(); b := u.nextLine();
if b.isEmpty then if b.isEmpty then
break; break;
FIXED_AUTO:
r.init(b); r.init(b);
canvas.Brush.Color:= color; canvas.Brush.Color:= color;
x := ScaleX(3,96); x := ScaleX(3,96);
// result // result
a := r.takeUntil(' ').takeMore(1).yield(); a := r.takeUntil(' ').takeMore(1).yield();
r.popFront; r.popFront;
writePart(a, x); if a <> '%FIX% ' then // the computed HintRect does not permit additional text
writePart(a, x);
// name // name
a := r.takeUntil('(').yield(); a := r.takeUntil('(').yield();
writePart(a, x); writePart(a, x);
@ -580,6 +583,15 @@ begin
a := r.takePair(')').takeMore(1).yield(); a := r.takePair(')').takeMore(1).yield();
r.popFront(); r.popFront();
writePart(a, x); writePart(a, x);
end
// `auto ident()` is formatted as `ident()` because `auto` in D is not a Type,
// so fix the formatting and go back.
else if r.empty() then
begin
if i > 128 then
exit;
b := '%FIX% ' + b;
goto FIXED_AUTO;
end; end;
// func args // func args
while not r.empty do while not r.empty do