mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 13:39:24 +02:00
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:
parent
b87224a3b5
commit
b7c129588d
@ -27,10 +27,10 @@
|
|||||||
</RunParams>
|
</RunParams>
|
||||||
<RequiredPackages Count="2">
|
<RequiredPackages Count="2">
|
||||||
<Item1>
|
<Item1>
|
||||||
<PackageName Value="CodeTools"/>
|
<PackageName Value="LCL"/>
|
||||||
</Item1>
|
</Item1>
|
||||||
<Item2>
|
<Item2>
|
||||||
<PackageName Value="LCL"/>
|
<PackageName Value="CodeTools"/>
|
||||||
</Item2>
|
</Item2>
|
||||||
</RequiredPackages>
|
</RequiredPackages>
|
||||||
<Units Count="1">
|
<Units Count="1">
|
||||||
|
@ -37,6 +37,7 @@ var
|
|||||||
NewCode: TCodeBuffer;
|
NewCode: TCodeBuffer;
|
||||||
NewX, NewY, NewTopLine: integer;
|
NewX, NewY, NewTopLine: integer;
|
||||||
begin
|
begin
|
||||||
|
aResY
|
||||||
// load the file
|
// load the file
|
||||||
if ParamCount>=1 then
|
if ParamCount>=1 then
|
||||||
Filename:=ExpandFileName(ParamStr(1))
|
Filename:=ExpandFileName(ParamStr(1))
|
||||||
|
@ -2120,14 +2120,25 @@ var
|
|||||||
Line: String;
|
Line: String;
|
||||||
CatName: String;
|
CatName: String;
|
||||||
SrcToken: String;
|
SrcToken: String;
|
||||||
|
IdChars: TSynIdentChars;
|
||||||
|
WordToken: String;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
Line:=GetLineText;
|
Line:=GetLineText;
|
||||||
p:=GetCursorTextXY;
|
p:=GetCursorTextXY;
|
||||||
if (p.x>length(Line)+1) or (Line='') then exit;
|
if (p.x>length(Line)+1) or (Line='') then exit;
|
||||||
CatName:=AutoCompleteOptionNames[Category];
|
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
|
for i:=0 to FCodeTemplates.Completions.Count-1 do begin
|
||||||
AToken:=FCodeTemplates.Completions[i];
|
AToken:=FCodeTemplates.Completions[i];
|
||||||
|
if AToken='' then continue;
|
||||||
|
if AToken[1] in IdChars then
|
||||||
|
SrcToken:=WordToken
|
||||||
|
else
|
||||||
SrcToken:=copy(Line,length(Line)-length(AToken)+1,length(AToken));
|
SrcToken:=copy(Line,length(Line)-length(AToken)+1,length(AToken));
|
||||||
//DebugLn(['TSourceEditor.AutoCompleteChar ',AToken,' SrcToken=',SrcToken,' CatName=',CatName,' Index=',FCodeTemplates.CompletionAttributes[i].IndexOfName(CatName)]);
|
//DebugLn(['TSourceEditor.AutoCompleteChar ',AToken,' SrcToken=',SrcToken,' CatName=',CatName,' Index=',FCodeTemplates.CompletionAttributes[i].IndexOfName(CatName)]);
|
||||||
if (AnsiCompareText(AToken,SrcToken)=0)
|
if (AnsiCompareText(AToken,SrcToken)=0)
|
||||||
|
Loading…
Reference in New Issue
Block a user