IDE: auto indent: debugging

git-svn-id: trunk@22114 -
This commit is contained in:
mattias 2009-10-12 14:42:13 +00:00
parent 9db44686b6
commit 07649baa56
2 changed files with 16 additions and 10 deletions

View File

@ -40,7 +40,7 @@ unit SynBeautifier;
interface
uses
Classes, SysUtils, SynEditMiscClasses, SynEditTextBase, SynEditPointClasses,
Classes, SysUtils, LCLProc, SynEditMiscClasses, SynEditTextBase, SynEditPointClasses,
SynEditKeyCmds;
type
@ -329,7 +329,7 @@ begin
CharMix := CharMix + CharMix[length(CharMix)]
else
CharMix := CharMix + ' ';
// to long, maybe too many tabs
// too long, maybe too many tabs
while (CharMix <> '') and
(GetCurrentIndent(FCurrentEditor, CharMix + OldCharMix, True) > Indent)
do
@ -407,15 +407,21 @@ begin
Indent := 0;
if IndentChars <> '' then
IndentChars := AdjustCharMix(Indent, IndentChars, Temp)
IndentChars := AdjustCharMix(Indent, IndentChars, {$IFDEF EnableIndenter}''{$ELSE}Temp{$ENDIF})
else
IndentChars := GetCharMix(LinePos, Indent, Temp, IndentCharsFromLinePos);
{$IFDEF EnableIndenter}
DebugLn(['TSynBeautifier.ApplyIndent IndentChars="',dbgstr(IndentChars),'" KeepOldIndent=',KeepOldIndent,' Indent=',Indent]);
{$ENDIF}
if not KeepOldIndent then
FCurrentLines.EditDelete(1, LinePos, OldLen);
//if not((FIndentType = sbitPositionCaret) and (FCurrentLines[LinePos] = '')) then
if IndentChars <> '' then
FCurrentLines.EditInsert(1, LinePos, IndentChars);
{$IFDEF EnableIndenter}
DebugLn(['TSynBeautifier.ApplyIndent Line="',dbgstr(FCurrentLines.ExpandedStrings[LinePos-1]),'"']);
{$ENDIF}
end;
function TSynBeautifier.GetCurrentIndent(Editor: TSynEditBase; const Line: string; Physical: boolean): Integer;

View File

@ -14162,8 +14162,7 @@ var
NestedComments: Boolean;
NewIndent: TFABIndentationPolicy;
EditorIndex: LongInt;
Dummy, Indent: Integer;
s: String;
Indent: Integer;
begin
Result := False;
{$IFNDEF EnableIndenter}
@ -14171,6 +14170,7 @@ begin
{$ENDIF}
if (Reason <> ecLineBreak) and (Reason <> ecInsertLine) then
exit;
debugln(['TMainIDE.OnSrcNoteBookGetIndent LogCaret=',dbgs(LogCaret),' FirstLinePos=',FirstLinePos,' LinesCount=',LinesCount]);
Result := True;
EditorIndex:=SrcEditor.PageIndex;
SaveSourceEditorChangesToCodeCache(EditorIndex);
@ -14181,11 +14181,11 @@ begin
if not CodeToolBoss.Indenter.GetIndent(CodeBuf.Source,p,NestedComments,NewIndent)
then exit;
if not NewIndent.IndentValid then exit;
Indent:=NewIndent.Indent+1;
Dummy := -1;
s := '';
SetIndentProc(FirstLinePos, Indent, Dummy, s, Dummy, False);
//DebugLn(['TMainIDE.OnSrcNoteBookGetIndent END Indent=',Indent,' ReplaceIndent=',ReplaceIndent,' BasedLine=',BasedLine]);
Indent:=NewIndent.Indent;
if (Reason=ecLineBreak) or (Reason=ecInsertLine) then begin
SetIndentProc(FirstLinePos+1, Indent, 0,' ');
DebugLn(['TMainIDE.OnSrcNoteBookGetIndent END Indent=',Indent]);
end;
end;
procedure TMainIDE.OnSrcNotebookMovingPage(Sender: TObject; OldPageIndex,