mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 05:39:18 +02:00
SynEdit, Code-Templates: fixed remove double semicolon (or end of token). regression from rev 20732 #d6b3aff8c9. Fix issue #14161
git-svn-id: trunk@20897 -
This commit is contained in:
parent
b16ed5daef
commit
9f69aa1518
@ -89,6 +89,7 @@ type
|
||||
destructor Destroy; override;
|
||||
|
||||
function SubstituteCodeMacros(SrcEdit: TSourceEditorInterface): boolean;
|
||||
procedure TrimEOTChar(eot: Char);
|
||||
|
||||
property EnableMacros: Boolean read FEnableMacros write FEnableMacros;
|
||||
property Indent: String read FIndent write FIndent;
|
||||
@ -362,6 +363,12 @@ begin
|
||||
Result := SubstituteMacros(FSrcTemplate);
|
||||
end;
|
||||
|
||||
procedure TLazTemplateParser.TrimEOTChar(eot: Char);
|
||||
begin
|
||||
if (FDestTemplate <> '') and (FDestTemplate[length(FDestTemplate)] = eot) then
|
||||
System.Delete(FDestTemplate, length(FDestTemplate), 1);
|
||||
end;
|
||||
|
||||
|
||||
function ExecuteCodeTemplate(SrcEdit: TSourceEditorInterface;
|
||||
const TemplateName, TemplateValue, TemplateComment,
|
||||
@ -431,14 +438,12 @@ begin
|
||||
end;
|
||||
|
||||
// delete double end separator (e.g. avoid creating two semicolons 'begin end;;')
|
||||
if (s<>'') and (System.Pos(s[length(s)],EndOfTokenChr)>0)
|
||||
and (AEditor.BlockEnd.Y>0) and (AEditor.BlockEnd.Y<=AEditor.Lines.Count)
|
||||
if (AEditor.BlockEnd.Y>0) and (AEditor.BlockEnd.Y<=AEditor.Lines.Count)
|
||||
then begin
|
||||
// template ends with an EndOfTokenChr
|
||||
// check if at the end of selection is the same character
|
||||
LineText:=AEditor.Lines[AEditor.BlockEnd.Y-1];
|
||||
if copy(LineText,AEditor.BlockEnd.X,1)=s[length(s)] then
|
||||
System.Delete(s,length(s),1);
|
||||
i := pos(LineText[AEditor.BlockEnd.X], EndOfTokenChr);
|
||||
if i > 0 then
|
||||
Parser.TrimEOTChar(EndOfTokenChr[i]);
|
||||
end;
|
||||
|
||||
i := AEditor.PluginCount - 1;
|
||||
|
Loading…
Reference in New Issue
Block a user