From 48a8ea5bb973af4ce59b00e3594f2e16739325a9 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Wed, 27 Apr 2016 22:51:18 +0200 Subject: [PATCH] fix, brace auto-clsoing, a case where it was not triggered new line after { followed by blanks --- src/ce_synmemo.pas | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ce_synmemo.pas b/src/ce_synmemo.pas index 20e94cf4..e7b4693d 100644 --- a/src/ce_synmemo.pas +++ b/src/ce_synmemo.pas @@ -1482,6 +1482,8 @@ end; {$REGION user input ------------------------------------------------------------} procedure TCESynMemo.KeyDown(var Key: Word; Shift: TShiftState); +var + line: string; begin case Key of VK_BACK: if fCallTipWin.Visible and (CaretX > 1) @@ -1489,20 +1491,22 @@ begin decCallTipsLvl; VK_RETURN: begin + line := LineText; if (fAutoCloseCurlyBrace in [autoCloseOnNewLineEof .. autoCloseOnNewLineLexically]) then case fAutoCloseCurlyBrace of - autoCloseOnNewLineAlways: if (CaretX > 1) and (LineText[LogicalCaretXY.X - 1] = '{') then + autoCloseOnNewLineAlways: if (CaretX > 1) and (line[LogicalCaretXY.X - 1] = '{') then begin Key := 0; curlyBraceCloseAndIndent(self); end; - autoCloseOnNewLineEof: if (CaretX > 1) and (LineText[LogicalCaretXY.X - 1] = '{') then - if (CaretY = Lines.Count) and (CaretX = LineText.length+1) then + autoCloseOnNewLineEof: if (CaretX > 1) and (line[LogicalCaretXY.X - 1] = '{') then + if (CaretY = Lines.Count) and (CaretX = line.length+1) then begin Key := 0; curlyBraceCloseAndIndent(self); end; - autoCloseOnNewLineLexically: if LogicalCaretXY.X - 1 >= lineText.length then + autoCloseOnNewLineLexically: if (LogicalCaretXY.X - 1 >= line.length) + or isBlank(line[LogicalCaretXY.X .. line.length]) then begin fLexToks.Clear; lex(lines.Text, fLexToks);