From b65bb860e45c47e3c48bf513aeafd9968daa2482 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Sat, 25 Apr 2020 03:03:53 +0200 Subject: [PATCH] prevent validation of the completion on operators --- CHANGELOG.md | 1 + src/u_synmemo.pas | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57d32d02..cddee3c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - DUB projects: dependencies specified with _path_ are recognized when their sources are in a sub folder taking as name the package name. (#29) - DUB runnables: document specific messages were not cleared between two calls to "Run DUB single file package". (#27) - Editor: case where brace auto close is triggered while in comment. (#31) +- Editor: prevent unexpected validation of properties in certain cases, such as `a.map` giving `a.mangleof` after `!`. ## Other diff --git a/src/u_synmemo.pas b/src/u_synmemo.pas index cdc3dd1b..079ed3a5 100644 --- a/src/u_synmemo.pas +++ b/src/u_synmemo.pas @@ -278,6 +278,7 @@ type procedure completionDeleteKey(sender: TObject); procedure getCompletionList; procedure completionFormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); + procedure completionFormUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char); function completionItemPaint(const AKey: string; ACanvas: TCanvas;X, Y: integer; Selected: boolean; Index: integer): boolean; procedure completionCodeCompletion(var value: string; SourceValue: string; @@ -1125,7 +1126,8 @@ begin fCompletion.OnCodeCompletion:=@completionCodeCompletion; fCompletion.OnPaintItem:= @completionItemPaint; fCompletion.OnKeyDelete:= @completionDeleteKey; - fCompletion.TheForm.OnKeyDown:= @completionFormKeyDown; + fCompletion.OnKeyDown:= @completionFormKeyDown; + fCompletion.OnUTF8KeyPress:= @completionFormUTF8KeyPress; fCompletion.CaseSensitive:=true; TStringList(fCompletion.ItemList).CaseSensitive:=true; fCompletion.LongLineHintType:=sclpNone; @@ -2828,7 +2830,6 @@ begin // these "stinky" lines are necessary because // the proc is called before deletion is effective // i.e the deleted char is still there... - // related issues #400 and #398 caretX := caretX - 1; ExecuteCommand(ecDeleteChar, #0, nil); caretX := caretX + 1; @@ -2892,6 +2893,21 @@ begin key := 13; end; +procedure TDexedMemo.completionFormUTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char); +const + s: string = '!()[],<>=+-/*%^|&@;?:{}~'; +var + c: char; +begin + for c in s do + if UTF8Key = c then + begin + UTF8Key := #0; + fCompletion.AddCharAtCursor(c); + break; + end +end; + function TDexedMemo.completionItemPaint(const AKey: string; ACanvas: TCanvas;X, Y: integer; Selected: boolean; Index: integer): boolean; var