From 0e785800e111bdca1771169f54b593c863b291b3 Mon Sep 17 00:00:00 2001 From: mattias Date: Wed, 18 Sep 2013 12:41:10 +0000 Subject: [PATCH] codetools: fixed removing first unit from second line git-svn-id: trunk@42859 - --- components/codetools/stdcodetools.pas | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/components/codetools/stdcodetools.pas b/components/codetools/stdcodetools.pas index 2f73a4c2ca..40d3bee7b4 100644 --- a/components/codetools/stdcodetools.pas +++ b/components/codetools/stdcodetools.pas @@ -1106,21 +1106,32 @@ begin if AtomIsChar(';') then begin // last unit in uses section -> delete whole uses section StartPos:=FindLineEndOrCodeInFrontOfPosition(UsesNode.StartPos,true,true); - if not SourceChangeCache.Replace(gtNone,gtNone, - StartPos,UsesNode.EndPos,'') then exit; + EndPos:=UsesNode.EndPos; end else begin // not last unit -> delete with comma behind EndPos:=FindLineEndOrCodeAfterPosition(CurPos.EndPos); if (EndPos>SrcLen) or (Src[EndPos] in [#10,#13]) then StartPos:=FindLineEndOrCodeInFrontOfPosition(StartPos);// delete space in front or even the empty line - if not SourceChangeCache.Replace(gtNone,gtNone, - StartPos,EndPos,'') then exit; end; end else begin - // not first unit in uses section -> delete with comma in front - if not SourceChangeCache.Replace(gtNone,gtNone, - EndPos,CurPos.StartPos,'') then exit; + // not first unit in uses section + if AtomIsChar(';') then begin + // last unit -> delete with comma in front + StartPos:=EndPos; + EndPos:=CurPos.StartPos; + end else if PositionsInSameLine(Src,EndPos,StartPos) then begin + // not first unit in line -> delete with comma in front + StartPos:=EndPos; + EndPos:=CurPos.StartPos; + end else begin + // first unit in line -> delete with comma behind + EndPos:=FindLineEndOrCodeAfterPosition(CurPos.EndPos); + if (EndPos>SrcLen) or (Src[EndPos] in [#10,#13]) then + StartPos:=FindLineEndOrCodeInFrontOfPosition(StartPos);// delete space in front or even the empty line + end; end; + if not SourceChangeCache.Replace(gtNone,gtNone,StartPos,EndPos,'') then + exit; if not SourceChangeCache.Apply then exit; Result:=true; exit;