Browse Source

Nested comment syntax highlight fix (compiler mode switches change).

Margers 1 month ago
parent
commit
7961b1f893
2 changed files with 9 additions and 3 deletions
  1. 8 2
      packages/ide/fpviews.pas
  2. 1 1
      packages/ide/weditor.pas

+ 8 - 2
packages/ide/fpviews.pas

@@ -139,6 +139,7 @@ type
       CompileStamp : longint;
       CompileStamp : longint;
       CodeCompleteTip: PFPToolTip;
       CodeCompleteTip: PFPToolTip;
       {for nested comments managment}
       {for nested comments managment}
+      SwitchesNestedComments : boolean;
       NestedComments : boolean;
       NestedComments : boolean;
       FixedNestedComments : TPoint;
       FixedNestedComments : TPoint;
       NestnessPoints:TNestnessPoints;
       NestnessPoints:TNestnessPoints;
@@ -1382,10 +1383,11 @@ begin
   IsAsmReservedWord:=IsFPAsmReservedWord(S);
   IsAsmReservedWord:=IsFPAsmReservedWord(S);
 end;
 end;
 
 
-function TSourceEditor.ParseSourceNestedComments(X,Y : sw_integer): boolean;
 const cModeNestedComments : array [TCompilerMode] of boolean =
 const cModeNestedComments : array [TCompilerMode] of boolean =
  (false,true{fpc},true{objfpc},false,false,false,false,false,false,false);
  (false,true{fpc},true{objfpc},false,false,false,false,false,false,false);
 
 
+function TSourceEditor.ParseSourceNestedComments(X,Y : sw_integer): boolean;
+
 function CompilerModeToNestedComments(AMode: String; ACurrentNestedComments:boolean):boolean;
 function CompilerModeToNestedComments(AMode: String; ACurrentNestedComments:boolean):boolean;
 var SourceCompilerMode : TCompilerMode;
 var SourceCompilerMode : TCompilerMode;
 begin
 begin
@@ -1441,6 +1443,7 @@ var CurrentCompilerMode : TCompilerMode;
 begin
 begin
   CurrentCompilerMode:=TCompilerMode(CompilerModeSwitches^.GetCurrSelParamID);
   CurrentCompilerMode:=TCompilerMode(CompilerModeSwitches^.GetCurrSelParamID);
   NestedComments:=cModeNestedComments[CurrentCompilerMode];
   NestedComments:=cModeNestedComments[CurrentCompilerMode];
+  SwitchesNestedComments:=NestedComments;
   ParseSourceNestedComments:=NestedComments;
   ParseSourceNestedComments:=NestedComments;
   ResultIsSet:=false;
   ResultIsSet:=false;
   RegisterNestnessPoint(0,0);
   RegisterNestnessPoint(0,0);
@@ -1617,7 +1620,7 @@ begin
     IsNestedComments:=NestedComments;
     IsNestedComments:=NestedComments;
   end else
   end else
   begin
   begin
-    lastNC:=NestedComments;
+    lastNC:=SwitchesNestedComments;
     if NestPos>0 then
     if NestPos>0 then
       for iPos:=0 to NestPos-1 do
       for iPos:=0 to NestPos-1 do
       begin
       begin
@@ -1673,6 +1676,9 @@ var Points : TNestnessPoints;
     iPos,iFrom,oNest : sw_integer;
     iPos,iFrom,oNest : sw_integer;
 begin
 begin
   NestedCommentsChangeCheck:=false;
   NestedCommentsChangeCheck:=false;
+  if SwitchesNestedComments<>cModeNestedComments[TCompilerMode(CompilerModeSwitches^.GetCurrSelParamID)] then
+    FixedNestedComments.Y:=2000000; {force to parse again}
+
   if (FixedNestedComments.Y>=CurLine) then
   if (FixedNestedComments.Y>=CurLine) then
   begin
   begin
     if FixedNestedComments.Y>=2000000 then
     if FixedNestedComments.Y>=2000000 then

+ 1 - 1
packages/ide/weditor.pas

@@ -2258,7 +2258,7 @@ begin
   AAttrs:=Attrs;
   AAttrs:=Attrs;
   if P^.Editor^.NestedCommentsChangeCheck(FromLine) then
   if P^.Editor^.NestedCommentsChangeCheck(FromLine) then
     AAttrs:=Attrs or attrForceFull;
     AAttrs:=Attrs or attrForceFull;
-  I:=DoUpdateAttrsRange(P^.Editor,FromLine,ToLine,Attrs);
+  I:=DoUpdateAttrsRange(P^.Editor,FromLine,ToLine,AAttrs);
   if (I<MinLine) or (MinLine=-1) then MinLine:=I;
   if (I<MinLine) or (MinLine=-1) then MinLine:=I;
 end;
 end;
 begin
 begin