IDE: code templates: when completion starts with identifier char then auto execute only if token starts at word boundary

git-svn-id: trunk@13032 -
This commit is contained in:
mattias 2007-11-26 11:39:07 +00:00
parent b87224a3b5
commit b7c129588d
3 changed files with 15 additions and 3 deletions

View File

@ -27,10 +27,10 @@
</RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="CodeTools"/>
<PackageName Value="LCL"/>
</Item1>
<Item2>
<PackageName Value="LCL"/>
<PackageName Value="CodeTools"/>
</Item2>
</RequiredPackages>
<Units Count="1">

View File

@ -37,6 +37,7 @@ var
NewCode: TCodeBuffer;
NewX, NewY, NewTopLine: integer;
begin
aResY
// load the file
if ParamCount>=1 then
Filename:=ExpandFileName(ParamStr(1))

View File

@ -2120,15 +2120,26 @@ var
Line: String;
CatName: String;
SrcToken: String;
IdChars: TSynIdentChars;
WordToken: String;
begin
Result:=false;
Line:=GetLineText;
p:=GetCursorTextXY;
if (p.x>length(Line)+1) or (Line='') then exit;
CatName:=AutoCompleteOptionNames[Category];
WordToken:=FEditor.GetWordAtRowCol(p);
if Assigned(FEditor.Highlighter) then
IdChars := FEditor.Highlighter.IdentChars
else
IdChars := ['a'..'z', 'A'..'Z'];
for i:=0 to FCodeTemplates.Completions.Count-1 do begin
AToken:=FCodeTemplates.Completions[i];
SrcToken:=copy(Line,length(Line)-length(AToken)+1,length(AToken));
if AToken='' then continue;
if AToken[1] in IdChars then
SrcToken:=WordToken
else
SrcToken:=copy(Line,length(Line)-length(AToken)+1,length(AToken));
//DebugLn(['TSourceEditor.AutoCompleteChar ',AToken,' SrcToken=',SrcToken,' CatName=',CatName,' Index=',FCodeTemplates.CompletionAttributes[i].IndexOfName(CatName)]);
if (AnsiCompareText(AToken,SrcToken)=0)
and (FCodeTemplates.CompletionAttributes[i].IndexOfName(CatName)>=0)