Переглянути джерело

Indent block when Persistent blocks are off

Margers 11 місяців тому
батько
коміт
28aaa672a1
1 змінених файлів з 14 додано та 0 видалено
  1. 14 0
      packages/ide/weditor.pas

+ 14 - 0
packages/ide/weditor.pas

@@ -5376,11 +5376,15 @@ var
   ey,i{,indlen} : Sw_integer;
   S,Ind : String;
   Pos : Tpoint;
+  WasPersistentBlocks : boolean;
 begin
   if IsReadOnly then Exit;
   if (SelStart.X=SelEnd.X) and (SelStart.Y=SelEnd.Y) then Exit;
   Lock;
   AddGroupedAction(eaIndentBlock);
+  WasPersistentBlocks:=IsFlagSet(efPersistentBlocks);
+  if not WasPersistentBlocks then
+    SetFlags(GetFlags or efPersistentBlocks);
   ey:=selend.y;
   if selend.x=0 then
    dec(ey);
@@ -5425,6 +5429,9 @@ begin
      AddAction(eaInsertText,Pos,Pos,Ind,GetFlags);
    end;
   SetCurPtr(CurPos.X,CurPos.Y);
+  {after SetCurPtr return PersistentBlocks as it was before}
+  if not WasPersistentBlocks then
+    SetFlags(GetFlags and (not longword(efPersistentBlocks)));
   { must be added manually here PM }
   AddAction(eaMoveCursor,Pos,CurPos,'',GetFlags);
   UpdateAttrsRange(SelStart.Y,SelEnd.Y,attrAll);
@@ -5439,11 +5446,15 @@ var
   ey,i,j,k,indlen : Sw_integer;
   S : String;
   Pos : TPoint;
+  WasPersistentBlocks : boolean;
 begin
   if IsReadOnly then Exit;
   if (SelStart.X=SelEnd.X) and (SelStart.Y=SelEnd.Y) then Exit;
   Lock;
   AddGroupedAction(eaUnindentBlock);
+  WasPersistentBlocks:=IsFlagSet(efPersistentBlocks);
+  if not WasPersistentBlocks then
+    SetFlags(GetFlags or efPersistentBlocks);
   ey:=selend.y;
   if selend.x=0 then
    dec(ey);
@@ -5501,6 +5512,9 @@ begin
        end;
    end;
   SetCurPtr(CurPos.X,CurPos.Y);
+  {after SetCurPtr return PersistentBlocks as it was before}
+  if not WasPersistentBlocks then
+    SetFlags(GetFlags and (not longword(efPersistentBlocks)));
   UpdateAttrsRange(SelStart.Y,SelEnd.Y,attrAll);
   DrawLines(CurPos.Y);
   SetModified(true);