mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-06 12:29:21 +01:00
IDE: Fix 'Invert assignment' with 2D arrays assignment. Issue #14996
git-svn-id: trunk@33634 -
This commit is contained in:
parent
1e01f9868a
commit
11fddf5d4a
@ -49,7 +49,8 @@ end;
|
|||||||
procedure DivideLines(Lines: TStrings; var PreList, AList, BList, PostList: TStrings);
|
procedure DivideLines(Lines: TStrings; var PreList, AList, BList, PostList: TStrings);
|
||||||
var
|
var
|
||||||
ALine, TrueFalse: String;
|
ALine, TrueFalse: String;
|
||||||
X, I, EqPos, SemiPos, WordEndPos: Integer;
|
t, f: Boolean;
|
||||||
|
X, I, EqPos, SemiPos, WordEndPos, BracketCount: Integer;
|
||||||
begin
|
begin
|
||||||
for X := 0 to Lines.Count-1 do begin
|
for X := 0 to Lines.Count-1 do begin
|
||||||
ALine := Trim(Lines[X]);
|
ALine := Trim(Lines[X]);
|
||||||
@ -62,8 +63,17 @@ begin
|
|||||||
while (I > 0) and (ALine[I] = ' ') do // Skip initial spaces
|
while (I > 0) and (ALine[I] = ' ') do // Skip initial spaces
|
||||||
Dec(I);
|
Dec(I);
|
||||||
WordEndPos := I+1;
|
WordEndPos := I+1;
|
||||||
while (I > 0) and (ALine[I] <> ' ') do // The word before :=
|
BracketCount := 0;
|
||||||
|
// Get the word before :=
|
||||||
|
while I > 0 do begin
|
||||||
|
if ALine[I] = ']' then
|
||||||
|
Inc(BracketCount)
|
||||||
|
else if ALine[I] = '[' then
|
||||||
|
Dec(BracketCount);
|
||||||
|
if (BracketCount = 0) and (ALine[I] = ' ') then
|
||||||
|
Break;
|
||||||
Dec(I);
|
Dec(I);
|
||||||
|
end;
|
||||||
// I points now at beginning of word - 1
|
// I points now at beginning of word - 1
|
||||||
Alist.Add(Copy(ALine, I+1, WordEndPos-(I+1)));
|
Alist.Add(Copy(ALine, I+1, WordEndPos-(I+1)));
|
||||||
BList.Add(Trim(Copy(ALine, EqPos+2, SemiPos-EqPos-2)));
|
BList.Add(Trim(Copy(ALine, EqPos+2, SemiPos-EqPos-2)));
|
||||||
@ -79,14 +89,11 @@ begin
|
|||||||
PostList.Add('');
|
PostList.Add('');
|
||||||
end;
|
end;
|
||||||
// Check if is being assigned true or false
|
// Check if is being assigned true or false
|
||||||
if CompareText(BList[X], 'True') = 0 then begin
|
t := CompareText(BList[X], 'True') = 0;
|
||||||
|
f := CompareText(BList[X], 'False') = 0;
|
||||||
|
if t or f then begin
|
||||||
TrueFalse := AList[X];
|
TrueFalse := AList[X];
|
||||||
AList[X] := 'False';
|
AList[X] := BoolToStr(not t, 'True', 'False');
|
||||||
BList[X] := TrueFalse;
|
|
||||||
end;
|
|
||||||
if CompareText(BList[X], 'False') = 0 then begin
|
|
||||||
TrueFalse := AList[X];
|
|
||||||
AList[X] := 'True';
|
|
||||||
BList[X] := TrueFalse;
|
BList[X] := TrueFalse;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user