several HL fixes

- when folds where deactivated, regions were not scanned correctly
- related: /+/ or /*/ were cinsidred as open/close pairs.
This commit is contained in:
Basile Burg 2015-02-24 18:35:41 +01:00
parent 7daa8e93d1
commit 93d33ed3b5
1 changed files with 24 additions and 47 deletions

View File

@ -518,8 +518,10 @@ begin
// block comments 1 // block comments 1
if fCurrRange.rangeKinds = [] then if readDelim(reader, fTokStop, '/*') then if fCurrRange.rangeKinds = [] then if readDelim(reader, fTokStop, '/*') then
begin begin
if readDelim(reader, fTokStop, '*') then fTokKind := tkDDocs fTokKind := tkCommt;
else fTokKind := tkCommt; if readDelim(reader, fTokStop, '*') then
if readDelim(reader, fTokStop, '/') then exit
else fTokKind := tkDDocs;
if readUntil(reader, fTokStop, '*/') then if readUntil(reader, fTokStop, '*/') then
exit; exit;
if fTokKind = tkDDocs then if fTokKind = tkDDocs then
@ -527,8 +529,7 @@ begin
else else
fCurrRange.rangeKinds += [rkBlockCom1]; fCurrRange.rangeKinds += [rkBlockCom1];
readLine(reader, fTokStop); readLine(reader, fTokStop);
if fkComments1 in fFoldKinds then StartCodeFoldBlock(nil, fkComments1 in fFoldKinds);
StartCodeFoldBlock(nil);
exit; exit;
end else readerReset; end else readerReset;
if (rkBlockCom1 in fCurrRange.rangeKinds) or (rkBlockDoc1 in fCurrRange.rangeKinds) then if (rkBlockCom1 in fCurrRange.rangeKinds) or (rkBlockDoc1 in fCurrRange.rangeKinds) then
@ -538,8 +539,7 @@ begin
if readUntil(reader, fTokStop, '*/') then if readUntil(reader, fTokStop, '*/') then
begin begin
fCurrRange.rangeKinds -= [rkBlockDoc1, rkBlockCom1]; fCurrRange.rangeKinds -= [rkBlockDoc1, rkBlockCom1];
if fkComments1 in fFoldKinds then EndCodeFoldBlock(fkComments1 in fFoldKinds );
EndCodeFoldBlock;
exit; exit;
end; end;
readLine(reader, fTokStop); readLine(reader, fTokStop);
@ -549,19 +549,18 @@ begin
// block comments 2 // block comments 2
if fCurrRange.rangeKinds = [] then if readDelim(reader, fTokStop, '/+') then if fCurrRange.rangeKinds = [] then if readDelim(reader, fTokStop, '/+') then
begin begin
fTokKind := tkCommt;
if readDelim(reader, fTokStop, '+') then
if readDelim(reader, fTokStop, '/') then exit
else fTokKind := tkDDocs;
if readUntil(reader, fTokStop, '+/') then exit;
inc(fCurrRange.nestedCommentsCount); inc(fCurrRange.nestedCommentsCount);
if readDelim(reader, fTokStop, '+') then fTokKind := tkDDocs if fTokKind = tkDDocs then
else fTokKind := tkCommt; fCurrRange.rangeKinds += [rkBlockDoc2]
if readUntil(reader, fTokStop, '+/') then else
begin fCurrRange.rangeKinds += [rkBlockCom2];
dec(fCurrRange.nestedCommentsCount);
exit;
end;
if fTokKind = tkDDocs then fCurrRange.rangeKinds += [rkBlockDoc2]
else fCurrRange.rangeKinds += [rkBlockCom2];
readLine(reader, fTokStop); readLine(reader, fTokStop);
if fkComments2 in fFoldKinds then StartCodeFoldBlock(nil, fkComments2 in fFoldKinds);
StartCodeFoldBlock(nil);
exit; exit;
end else readerReset; end else readerReset;
if (rkBlockCom2 in fCurrRange.rangeKinds) or (rkBlockDoc2 in fCurrRange.rangeKinds) then if (rkBlockCom2 in fCurrRange.rangeKinds) or (rkBlockDoc2 in fCurrRange.rangeKinds) then
@ -577,8 +576,7 @@ begin
if fCurrRange.nestedCommentsCount <> 0 then if fCurrRange.nestedCommentsCount <> 0 then
exit; exit;
fCurrRange.rangeKinds -= [rkBlockDoc2, rkBlockCom2]; fCurrRange.rangeKinds -= [rkBlockDoc2, rkBlockCom2];
if fkComments2 in fFoldKinds then EndCodeFoldBlock(fkComments2 in fFoldKinds);
EndCodeFoldBlock;
exit; exit;
end; end;
readLine(reader, fTokStop); readLine(reader, fTokStop);
@ -618,8 +616,7 @@ begin
end; end;
end; end;
fCurrRange.rangeKinds += [rkString1]; fCurrRange.rangeKinds += [rkString1];
if fkStrings in fFoldKinds then StartCodeFoldBlock(nil, fkStrings in fFoldKinds);
StartCodeFoldBlock(nil);
exit; exit;
end else _postString1: readerReset; end else _postString1: readerReset;
if rkString1 in fCurrRange.rangeKinds then if rkString1 in fCurrRange.rangeKinds then
@ -640,8 +637,7 @@ begin
fCurrRange.rangeKinds -= [rkString1]; fCurrRange.rangeKinds -= [rkString1];
readDelim(reader, fTokStop, stringPostfixes); readDelim(reader, fTokStop, stringPostfixes);
fCurrRange.rString := false; fCurrRange.rString := false;
if fkStrings in fFoldKinds then EndCodeFoldBlock(fkStrings in fFoldKinds);
EndCodeFoldBlock();
exit; exit;
end end
else break; else break;
@ -661,8 +657,7 @@ begin
end; end;
fCurrRange.rangeKinds += [rkString2]; fCurrRange.rangeKinds += [rkString2];
readLine(reader, fTokStop); readLine(reader, fTokStop);
if fkStrings in fFoldKinds then StartCodeFoldBlock(nil, fkStrings in fFoldKinds);
StartCodeFoldBlock(nil);
exit; exit;
end else readerReset; end else readerReset;
if rkString2 in fCurrRange.rangeKinds then if rkString2 in fCurrRange.rangeKinds then
@ -671,8 +666,7 @@ begin
if readUntil(reader, fTokStop, '`') then if readUntil(reader, fTokStop, '`') then
begin begin
fCurrRange.rangeKinds -= [rkString2]; fCurrRange.rangeKinds -= [rkString2];
if fkStrings in fFoldKinds then EndCodeFoldBlock(fkStrings in fFoldKinds);
EndCodeFoldBlock();
readDelim(reader, fTokStop, stringPostfixes); readDelim(reader, fTokStop, stringPostfixes);
exit; exit;
end; end;
@ -686,8 +680,7 @@ begin
fTokKind := tkIdent; fTokKind := tkIdent;
inc(fCurrRange.tokenStringBracketsCount); inc(fCurrRange.tokenStringBracketsCount);
fCurrRange.rangeKinds += [rkTokString]; fCurrRange.rangeKinds += [rkTokString];
if (fkBrackets in fFoldKinds) then StartCodeFoldBlock(nil, fkBrackets in fFoldKinds);
StartCodeFoldBlock(nil);
exit; exit;
end else readerReset; end else readerReset;
@ -712,21 +705,6 @@ begin
exit; exit;
end else readerReset; end else readerReset;
// hex litterals
{if readDelim(reader, fTokStop, '0x') then
begin
readWhile(reader, fTokStop, hexaChars);
if not tryReadDelim(reader, fTokStop, 'Lu') then
if not tryReadDelim(reader, fTokStop, 'LU') then
if not tryReadDelim(reader, fTokStop, 'uL') then
if not tryReadDelim(reader, fTokStop, 'UL') then
if not tryReadDelim(reader, fTokStop, 'L') then
if not tryReadDelim(reader, fTokStop, 'u') then
tryReadDelim(reader, fTokStop, 'U');
fTokKind := tkNumbr;
exit;
end else readerReset;}
// numbers 1 // numbers 1
if (isNumber(reader^)) then if (isNumber(reader^)) then
begin begin
@ -740,11 +718,10 @@ begin
begin begin
fTokKind := tkSymbl; fTokKind := tkSymbl;
case reader^ of case reader^ of
'{': if (fkBrackets in fFoldKinds) then StartCodeFoldBlock(nil); '{': StartCodeFoldBlock(nil,fkBrackets in fFoldKinds);
'}': '}':
begin begin
if (fkBrackets in fFoldKinds) then EndCodeFoldBlock(fkBrackets in fFoldKinds);
EndCodeFoldBlock;
if (reader^ = '}') and (rkAsm in fCurrRange.rangeKinds) then if (reader^ = '}') and (rkAsm in fCurrRange.rangeKinds) then
fCurrRange.rangeKinds -= [rkAsm]; ; fCurrRange.rangeKinds -= [rkAsm]; ;
if (rkTokString in fCurrRange.rangeKinds) then if (rkTokString in fCurrRange.rangeKinds) then