Browse Source

Syntax highlight fix for indent and unindent block.

Margers 1 month ago
parent
commit
12e4775349
1 changed files with 14 additions and 6 deletions
  1. 14 6
      packages/ide/weditor.pas

+ 14 - 6
packages/ide/weditor.pas

@@ -5791,15 +5791,16 @@ var
   ey,i,Indlen : Sw_Integer;
   ey,i,Indlen : Sw_Integer;
   S,Ind : Sw_AString;
   S,Ind : Sw_AString;
   Pos : Tpoint;
   Pos : Tpoint;
-  WasPersistentBlocks : boolean;
+  {WasPersistentBlocks : boolean;}
 begin
 begin
   if IsReadOnly then Exit;
   if IsReadOnly then Exit;
   if (SelStart.X=SelEnd.X) and (SelStart.Y=SelEnd.Y) then Exit;
   if (SelStart.X=SelEnd.X) and (SelStart.Y=SelEnd.Y) then Exit;
   Lock;
   Lock;
   AddGroupedAction(eaIndentBlock);
   AddGroupedAction(eaIndentBlock);
+  { as SetCurPtr commented out, no need take care of Persistent Blocks
   WasPersistentBlocks:=IsFlagSet(efPersistentBlocks);
   WasPersistentBlocks:=IsFlagSet(efPersistentBlocks);
   if not WasPersistentBlocks then
   if not WasPersistentBlocks then
-    SetFlags(GetFlags or efPersistentBlocks);
+    SetFlags(GetFlags or efPersistentBlocks); }
   ey:=selend.y;
   ey:=selend.y;
   if selend.x=0 then
   if selend.x=0 then
    dec(ey);
    dec(ey);
@@ -5847,10 +5848,12 @@ begin
      Pos.X:=0;Pos.Y:=i;
      Pos.X:=0;Pos.Y:=i;
      AddAction(eaInsertText,Pos,Pos,Ind,GetFlags);
      AddAction(eaInsertText,Pos,Pos,Ind,GetFlags);
    end;
    end;
-  SetCurPtr(CurPos.X,CurPos.Y);
+  { this removes selection if Shift is pressed as well and we do not change cursor position anyway
+  SetCurPtr(CurPos.X,CurPos.Y); }
   {after SetCurPtr return PersistentBlocks as it was before}
   {after SetCurPtr return PersistentBlocks as it was before}
+  { as SetCurPtr commented out, no need take care of Persistent Blocks
   if not WasPersistentBlocks then
   if not WasPersistentBlocks then
-    SetFlags(GetFlags and (not longword(efPersistentBlocks)));
+    SetFlags(GetFlags and (not longword(efPersistentBlocks))); }
   { must be added manually here PM }
   { must be added manually here PM }
   AddAction(eaMoveCursor,Pos,CurPos,'',GetFlags);
   AddAction(eaMoveCursor,Pos,CurPos,'',GetFlags);
   UpdateAttrsRange(SelStart.Y,SelEnd.Y,attrAll);
   UpdateAttrsRange(SelStart.Y,SelEnd.Y,attrAll);
@@ -5865,15 +5868,17 @@ var
   ey,i,j,k,indlen : Sw_integer;
   ey,i,j,k,indlen : Sw_integer;
   S : Sw_AString;
   S : Sw_AString;
   Pos : TPoint;
   Pos : TPoint;
-  WasPersistentBlocks : boolean;
+  {WasPersistentBlocks : boolean;}
 begin
 begin
   if IsReadOnly then Exit;
   if IsReadOnly then Exit;
   if (SelStart.X=SelEnd.X) and (SelStart.Y=SelEnd.Y) then Exit;
   if (SelStart.X=SelEnd.X) and (SelStart.Y=SelEnd.Y) then Exit;
   Lock;
   Lock;
   AddGroupedAction(eaUnindentBlock);
   AddGroupedAction(eaUnindentBlock);
+  {  as SetCurPtr commented out, no need take care of Persistent Blocks
   WasPersistentBlocks:=IsFlagSet(efPersistentBlocks);
   WasPersistentBlocks:=IsFlagSet(efPersistentBlocks);
   if not WasPersistentBlocks then
   if not WasPersistentBlocks then
     SetFlags(GetFlags or efPersistentBlocks);
     SetFlags(GetFlags or efPersistentBlocks);
+  }
   ey:=selend.y;
   ey:=selend.y;
   if selend.x=0 then
   if selend.x=0 then
    dec(ey);
    dec(ey);
@@ -5936,10 +5941,13 @@ begin
          AddAction(eaDeleteText,Pos,Pos,CharStr(' ',k),GetFlags);
          AddAction(eaDeleteText,Pos,Pos,CharStr(' ',k),GetFlags);
        end;
        end;
    end;
    end;
-  SetCurPtr(CurPos.X,CurPos.Y);
+  { Removes selection if Shift is pressed as well and we do not change cursor position anyway
+  SetCurPtr(CurPos.X,CurPos.Y); }
   {after SetCurPtr return PersistentBlocks as it was before}
   {after SetCurPtr return PersistentBlocks as it was before}
+  { as SetCurPtr commented out, no need take care of Persistent Blocks
   if not WasPersistentBlocks then
   if not WasPersistentBlocks then
     SetFlags(GetFlags and (not longword(efPersistentBlocks)));
     SetFlags(GetFlags and (not longword(efPersistentBlocks)));
+  }
   UpdateAttrsRange(SelStart.Y,SelEnd.Y,attrAll);
   UpdateAttrsRange(SelStart.Y,SelEnd.Y,attrAll);
   DrawLines(CurPos.Y);
   DrawLines(CurPos.Y);
   SetModified(true);
   SetModified(true);