mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-04 07:42:59 +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;
|
destructor Destroy; override;
|
||||||
|
|
||||||
function SubstituteCodeMacros(SrcEdit: TSourceEditorInterface): boolean;
|
function SubstituteCodeMacros(SrcEdit: TSourceEditorInterface): boolean;
|
||||||
|
procedure TrimEOTChar(eot: Char);
|
||||||
|
|
||||||
property EnableMacros: Boolean read FEnableMacros write FEnableMacros;
|
property EnableMacros: Boolean read FEnableMacros write FEnableMacros;
|
||||||
property Indent: String read FIndent write FIndent;
|
property Indent: String read FIndent write FIndent;
|
||||||
@ -362,6 +363,12 @@ begin
|
|||||||
Result := SubstituteMacros(FSrcTemplate);
|
Result := SubstituteMacros(FSrcTemplate);
|
||||||
end;
|
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;
|
function ExecuteCodeTemplate(SrcEdit: TSourceEditorInterface;
|
||||||
const TemplateName, TemplateValue, TemplateComment,
|
const TemplateName, TemplateValue, TemplateComment,
|
||||||
@ -431,14 +438,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// delete double end separator (e.g. avoid creating two semicolons 'begin end;;')
|
// delete double end separator (e.g. avoid creating two semicolons 'begin end;;')
|
||||||
if (s<>'') and (System.Pos(s[length(s)],EndOfTokenChr)>0)
|
if (AEditor.BlockEnd.Y>0) and (AEditor.BlockEnd.Y<=AEditor.Lines.Count)
|
||||||
and (AEditor.BlockEnd.Y>0) and (AEditor.BlockEnd.Y<=AEditor.Lines.Count)
|
|
||||||
then begin
|
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];
|
LineText:=AEditor.Lines[AEditor.BlockEnd.Y-1];
|
||||||
if copy(LineText,AEditor.BlockEnd.X,1)=s[length(s)] then
|
i := pos(LineText[AEditor.BlockEnd.X], EndOfTokenChr);
|
||||||
System.Delete(s,length(s),1);
|
if i > 0 then
|
||||||
|
Parser.TrimEOTChar(EndOfTokenChr[i]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
i := AEditor.PluginCount - 1;
|
i := AEditor.PluginCount - 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user