From b7c129588d15368394ef1f85faaf1f061d78ce0a Mon Sep 17 00:00:00 2001 From: mattias Date: Mon, 26 Nov 2007 11:39:07 +0000 Subject: [PATCH] IDE: code templates: when completion starts with identifier char then auto execute only if token starts at word boundary git-svn-id: trunk@13032 - --- .../examples/replaceresourcedirectives.lpi | 4 ++-- .../examples/replaceresourcedirectives.lpr | 1 + ide/uniteditor.pp | 13 ++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/components/codetools/examples/replaceresourcedirectives.lpi b/components/codetools/examples/replaceresourcedirectives.lpi index 2e358f18ae..e0213b5def 100644 --- a/components/codetools/examples/replaceresourcedirectives.lpi +++ b/components/codetools/examples/replaceresourcedirectives.lpi @@ -27,10 +27,10 @@ - + - + diff --git a/components/codetools/examples/replaceresourcedirectives.lpr b/components/codetools/examples/replaceresourcedirectives.lpr index cb6ea257c1..109e59da19 100644 --- a/components/codetools/examples/replaceresourcedirectives.lpr +++ b/components/codetools/examples/replaceresourcedirectives.lpr @@ -37,6 +37,7 @@ var NewCode: TCodeBuffer; NewX, NewY, NewTopLine: integer; begin + aResY // load the file if ParamCount>=1 then Filename:=ExpandFileName(ParamStr(1)) diff --git a/ide/uniteditor.pp b/ide/uniteditor.pp index 5ebd17039f..930af1892e 100644 --- a/ide/uniteditor.pp +++ b/ide/uniteditor.pp @@ -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)