mirror of https://gitlab.com/basile.b/dexed.git
improve curly brace auto-closing and support CTRL to skip auto closing, clsoe #342
This commit is contained in:
parent
e4fd4d7672
commit
ef2ca016ff
|
@ -1591,6 +1591,7 @@ var
|
||||||
beg: string = '';
|
beg: string = '';
|
||||||
numTabs: integer = 0;
|
numTabs: integer = 0;
|
||||||
numSpac: integer = 0;
|
numSpac: integer = 0;
|
||||||
|
numSkip: integer = 0;
|
||||||
begin
|
begin
|
||||||
if not fIsDSource and not alwaysAdvancedFeatures then
|
if not fIsDSource and not alwaysAdvancedFeatures then
|
||||||
exit;
|
exit;
|
||||||
|
@ -1601,10 +1602,18 @@ begin
|
||||||
if i < 0 then
|
if i < 0 then
|
||||||
break;
|
break;
|
||||||
beg := Lines[i];
|
beg := Lines[i];
|
||||||
if (Pos('{', beg) = 0) then
|
if (Pos('}', beg) <> 0) then
|
||||||
i -= 1
|
begin
|
||||||
|
numSkip += 1;
|
||||||
|
end
|
||||||
|
else if (Pos('{', beg) <> 0) then
|
||||||
|
begin
|
||||||
|
numSkip -= 1;
|
||||||
|
end;
|
||||||
|
if numSkip < 0 then
|
||||||
|
break
|
||||||
else
|
else
|
||||||
break;
|
i -= 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
for i:= 1 to beg.length do
|
for i:= 1 to beg.length do
|
||||||
|
@ -3337,6 +3346,8 @@ begin
|
||||||
begin
|
begin
|
||||||
fCanDscan:=true;
|
fCanDscan:=true;
|
||||||
line := LineText;
|
line := LineText;
|
||||||
|
if [ssCtrl] <> Shift then
|
||||||
|
begin
|
||||||
case fAutoCloseCurlyBrace of
|
case fAutoCloseCurlyBrace of
|
||||||
autoCloseOnNewLineAlways: if (CaretX > 1) and (line[LogicalCaretXY.X - 1] = '{') then
|
autoCloseOnNewLineAlways: if (CaretX > 1) and (line[LogicalCaretXY.X - 1] = '{') then
|
||||||
begin
|
begin
|
||||||
|
@ -3350,7 +3361,6 @@ begin
|
||||||
curlyBraceCloseAndIndent;
|
curlyBraceCloseAndIndent;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (fAutoCloseCurlyBrace = autoCloseOnNewLineLexically) or
|
if (fAutoCloseCurlyBrace = autoCloseOnNewLineLexically) or
|
||||||
fSmartDdocNewline then
|
fSmartDdocNewline then
|
||||||
begin
|
begin
|
||||||
|
@ -3386,6 +3396,8 @@ begin
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end
|
||||||
|
else shift := [];
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
inherited;
|
inherited;
|
||||||
|
|
Loading…
Reference in New Issue