From fb69b8b59d3a187eeddbb21ea9392801bc5258de Mon Sep 17 00:00:00 2001 From: ondrej Date: Thu, 12 Nov 2015 17:01:27 +0000 Subject: [PATCH] IDE, codetools, synedit: fixed identifier completion of identifiers prefixed with &. git-svn-id: trunk@50323 - --- components/synedit/syncompletion.pas | 13 +++++++++++-- components/synedit/synhighlighterpas.pp | 2 +- ide/sourceeditprocs.pas | 7 +------ 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/components/synedit/syncompletion.pas b/components/synedit/syncompletion.pas index 3e30a60bad..038a0dbca1 100644 --- a/components/synedit/syncompletion.pas +++ b/components/synedit/syncompletion.pas @@ -1735,6 +1735,7 @@ var Value, CurLine: string; NewBlockBegin, NewBlockEnd: TPoint; LogCaret: TPoint; + HighlighterIdentChars: TSynIdentChars; begin //debugln('TSynCompletion.Validate ',dbgsName(Sender),' ',dbgs(Shift),' Position=',dbgs(Position)); F := Sender as TSynBaseCompletionForm; @@ -1744,11 +1745,17 @@ begin BeginUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TSynCompletion.Validate'){$ENDIF}; BeginUpdate; try + if Editor.Highlighter<>nil then + HighlighterIdentChars := Editor.Highlighter.IdentChars + else + HighlighterIdentChars := []; LogCaret := LogicalCaretXY; NewBlockBegin:=LogCaret; CurLine:=Lines[NewBlockBegin.Y - 1]; while (NewBlockBegin.X>1) and (NewBlockBegin.X-1<=length(CurLine)) - and (IsIdentifierChar(@CurLine[NewBlockBegin.X-1])) do + and ((IsIdentifierChar(@CurLine[NewBlockBegin.X-1])) + or (CurLine[NewBlockBegin.X-1] in HighlighterIdentChars)) + do dec(NewBlockBegin.X); //BlockBegin:=NewBlockBegin; if ssShift in Shift then begin @@ -1759,7 +1766,9 @@ begin NewBlockEnd := LogCaret; CurLine:=Lines[NewBlockEnd.Y - 1]; while (NewBlockEnd.X<=length(CurLine)) - and (IsIdentifierChar(@CurLine[NewBlockEnd.X])) do + and ((IsIdentifierChar(@CurLine[NewBlockEnd.X])) + or (CurLine[NewBlockEnd.X] in HighlighterIdentChars)) + do inc(NewBlockEnd.X); end; //debugln('TSynCompletion.Validate B Position=',dbgs(Position)); diff --git a/components/synedit/synhighlighterpas.pp b/components/synedit/synhighlighterpas.pp index 4c15a1eafd..0fe7179a39 100644 --- a/components/synedit/synhighlighterpas.pp +++ b/components/synedit/synhighlighterpas.pp @@ -4226,7 +4226,7 @@ end; { TSynPasSyn.UseUserSettings } function TSynPasSyn.GetIdentChars: TSynIdentChars; begin - Result := ['_', '0'..'9', 'a'..'z', 'A'..'Z']; + Result := ['&', '_', '0'..'9', 'a'..'z', 'A'..'Z']; end; class function TSynPasSyn.GetLanguageName: string; diff --git a/ide/sourceeditprocs.pas b/ide/sourceeditprocs.pas index 08818934f5..dce20e2f8b 100644 --- a/ide/sourceeditprocs.pas +++ b/ide/sourceeditprocs.pas @@ -626,12 +626,7 @@ begin end; //Add the '&' character to prefixed identifiers - if (iliNeedsAmpersand in IdentItem.Flags) and - //check if there is already an '&' in front of this atom - ((IdentList.StartAtom.StartPos-1 > IdentList.StartContext.Tool.SrcLen) or //StartPos-1 is out-of-scope - (IdentList.StartAtom.StartPos-1 < 1) or //StartPos-1 is out-of-scope - (IdentList.StartContext.Tool.Src[IdentList.StartAtom.StartPos-1] <> '&')) //StartPos is in-scope and not & - then + if (iliNeedsAmpersand in IdentItem.Flags) then Result := '&' + Result; case ValueType of