Menu

#28 Enhancement to ParamComplete demo

open
nobody
None
5
2007-02-17
2007-02-17
No

While the ParamComplete demo is good it has a flaw in that it doesn't take into account string parameters that may have a comma in them.

For example:
Somefunction(a, 'the, end', b)

So I'm submitting this patch to take into account string parameters that might contain commas. This works for me, you mileage may vary.

Original code (scpParamsExecute event handler):

...
if LocLine[TmpX] = ',' then
begin
inc(TmpLocation);
dec(TmpX);
end
...

Patched code:

...
if LocLine[TmpX] = ',' then
begin
if GetHighlighterAttriAtRowCol(BufferCoord(TmpX,CaretY),wToken,wAttr) then
begin
if wAttr = Highlighter.StringAttribute then
begin
while wAttr = Highlighter.StringAttribute do
begin
dec(TmpX);
GetHighlighterAttriAtRowCol(BufferCoord(TmpX,CaretY),wToken,wAttr);
end;
end
else
begin
inc(TmpLocation);
dec(TmpX);
end;
end
else
begin //This part may not be necessary, but I've left it in to make it compatible to the original demo code.
inc(TmpLocation);
dec(TmpX);
end;
end
...

Discussion


Log in to post a comment.