mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 08:19:27 +02:00
codetools: block completion: consider comments in front of insert pos
git-svn-id: trunk@26737 -
This commit is contained in:
parent
eeb043e59e
commit
0d135358b4
@ -52,7 +52,6 @@ begin
|
|||||||
// setup the Options
|
// setup the Options
|
||||||
Options:=TCodeToolsOptions.Create;
|
Options:=TCodeToolsOptions.Create;
|
||||||
try
|
try
|
||||||
|
|
||||||
// setup your paths
|
// setup your paths
|
||||||
writeln('Config=',ConfigFilename);
|
writeln('Config=',ConfigFilename);
|
||||||
if FileExists(ConfigFilename) then begin
|
if FileExists(ConfigFilename) then begin
|
||||||
|
@ -5311,6 +5311,12 @@ var
|
|||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function InsertPosAtCursor: integer;
|
||||||
|
begin
|
||||||
|
Result:=BasicCodeTools.FindLineEndOrCodeInFrontOfPosition(Src,
|
||||||
|
CurPos.StartPos,CleanCursorPos,Scanner.NestedComments);
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
MoveCursorToNodeStart(StartNode);
|
MoveCursorToNodeStart(StartNode);
|
||||||
@ -5404,7 +5410,7 @@ var
|
|||||||
{$IFDEF ShowCompleteBlock}
|
{$IFDEF ShowCompleteBlock}
|
||||||
DebugLn(['ReadStatements NeedCompletion: between same indented ',CleanPosToStr(CurPos.StartPos),' Indent=',Indent,' < CursorBlockOuterIndent=',CursorBlockOuterIndent,' < CursorBlockInnerIndent=',CursorBlockInnerIndent,' Parent.InnerStartPos=',CleanPosToStr(Stack.Stack[CursorBlockLvl-1].InnerStartPos)]);
|
DebugLn(['ReadStatements NeedCompletion: between same indented ',CleanPosToStr(CurPos.StartPos),' Indent=',Indent,' < CursorBlockOuterIndent=',CursorBlockOuterIndent,' < CursorBlockInnerIndent=',CursorBlockInnerIndent,' Parent.InnerStartPos=',CleanPosToStr(Stack.Stack[CursorBlockLvl-1].InnerStartPos)]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
NeedCompletion:=CurPos.StartPos;
|
NeedCompletion:=InsertPosAtCursor;
|
||||||
end;
|
end;
|
||||||
end else if (Indent<CursorBlockOuterIndent) then begin
|
end else if (Indent<CursorBlockOuterIndent) then begin
|
||||||
// for example:
|
// for example:
|
||||||
@ -5420,7 +5426,7 @@ var
|
|||||||
{$IFDEF ShowCompleteBlock}
|
{$IFDEF ShowCompleteBlock}
|
||||||
DebugLn(['ReadStatements NeedCompletion: at out indented ',CleanPosToStr(CurPos.StartPos),' Indent=',Indent,' < CursorBlockOuterIndent=',CursorBlockOuterIndent,' < CursorBlockInnerIndent=',CursorBlockInnerIndent]);
|
DebugLn(['ReadStatements NeedCompletion: at out indented ',CleanPosToStr(CurPos.StartPos),' Indent=',Indent,' < CursorBlockOuterIndent=',CursorBlockOuterIndent,' < CursorBlockInnerIndent=',CursorBlockInnerIndent]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
NeedCompletion:=CurPos.StartPos;
|
NeedCompletion:=InsertPosAtCursor;
|
||||||
end else if CursorAtEmptyLine or CursorInEmptyStatement
|
end else if CursorAtEmptyLine or CursorInEmptyStatement
|
||||||
or (FindNextNonSpace(Src,CleanCursorPos)=CurPos.StartPos) then begin
|
or (FindNextNonSpace(Src,CleanCursorPos)=CurPos.StartPos) then begin
|
||||||
{ for example:
|
{ for example:
|
||||||
@ -5603,7 +5609,7 @@ var
|
|||||||
{$IFDEF ShowCompleteBlock}
|
{$IFDEF ShowCompleteBlock}
|
||||||
DebugLn(['ReadStatements NeedCompletion: unexpected else at ',CleanPosToStr(CurPos.StartPos),': missing end. block start: ',CleanPosToStr(Stack.Stack[Stack.Top].StartPos)]);
|
DebugLn(['ReadStatements NeedCompletion: unexpected else at ',CleanPosToStr(CurPos.StartPos),': missing end. block start: ',CleanPosToStr(Stack.Stack[Stack.Top].StartPos)]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
NeedCompletion:=CurPos.StartPos;
|
NeedCompletion:=InsertPosAtCursor;
|
||||||
end;
|
end;
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
@ -5614,7 +5620,7 @@ var
|
|||||||
{$IFDEF ShowCompleteBlock}
|
{$IFDEF ShowCompleteBlock}
|
||||||
DebugLn(['ReadStatements NeedCompletion: unexpected else at ',CleanPosToStr(CurPos.StartPos),': missing semicolon or until. block start: ',CleanPosToStr(Stack.Stack[Stack.Top].StartPos)]);
|
DebugLn(['ReadStatements NeedCompletion: unexpected else at ',CleanPosToStr(CurPos.StartPos),': missing semicolon or until. block start: ',CleanPosToStr(Stack.Stack[Stack.Top].StartPos)]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
NeedCompletion:=CurPos.StartPos;
|
NeedCompletion:=InsertPosAtCursor;
|
||||||
end;
|
end;
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
@ -5656,7 +5662,7 @@ var
|
|||||||
{$IFDEF ShowCompleteBlock}
|
{$IFDEF ShowCompleteBlock}
|
||||||
DebugLn(['ReadStatements NeedCompletion: at ',CleanPosToStr(CurPos.StartPos),' Indent=',Indent,' < CursorBlockInnerIndent=',CursorBlockInnerIndent]);
|
DebugLn(['ReadStatements NeedCompletion: at ',CleanPosToStr(CurPos.StartPos),' Indent=',Indent,' < CursorBlockInnerIndent=',CursorBlockInnerIndent]);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
NeedCompletion:=CurPos.StartPos;
|
NeedCompletion:=InsertPosAtCursor;
|
||||||
end else begin
|
end else begin
|
||||||
// for example:
|
// for example:
|
||||||
// begin
|
// begin
|
||||||
|
Loading…
Reference in New Issue
Block a user