IDE: word+identifier completion: toggle replace word or left side on shift

git-svn-id: trunk@52868 -
This commit is contained in:
mattias 2016-08-24 10:21:37 +00:00
parent 2be768995c
commit b26152988c
2 changed files with 10 additions and 9 deletions

View File

@ -368,6 +368,7 @@ type
FExecCommandID: TSynEditorCommand;
FEndOfTokenChr: string;
FOnCodeCompletion: TCodeCompletionEvent;
FToggleReplacesWhole: boolean;
procedure Cancel(Sender: TObject);
procedure Validate(Sender: TObject; KeyChar: TUTF8Char; Shift: TShiftState);
function GetPreviousToken(FEditor: TCustomSynEdit): string;
@ -397,6 +398,7 @@ type
read FOnCodeCompletion write FOnCodeCompletion;
property ExecCommandID: TSynEditorCommand read FExecCommandID write FExecCommandID;
property Editor;
property ToggleReplaceWhole: boolean read FToggleReplacesWhole write FToggleReplacesWhole;// false=shift replaces left side, true=shift replaces whole word
end;
{ TSynAutoComplete }
@ -1761,10 +1763,7 @@ begin
do
dec(NewBlockBegin.X);
//BlockBegin:=NewBlockBegin;
if ssShift in Shift then begin
// replace only prefix
NewBlockEnd := LogCaret;
end else begin
if (ssShift in Shift)=ToggleReplaceWhole then begin
// replace the whole word
NewBlockEnd := LogCaret;
CurLine:=Lines[NewBlockEnd.Y - 1];
@ -1773,6 +1772,9 @@ begin
or (CurLine[NewBlockEnd.X] in HighlighterIdentChars))
do
inc(NewBlockEnd.X);
end else begin
// replace only prefix
NewBlockEnd := LogCaret;
end;
//debugln('TSynCompletion.Validate B Position=',dbgs(Position));
if Position>=0 then begin

View File

@ -2114,13 +2114,16 @@ Begin
Prefix := CurrentString;
case CurrentCompletionType of
ctIdentCompletion:
if not InitIdentCompletionValues(S) then begin
if InitIdentCompletionValues(S) then begin
ToggleReplaceWhole:=not CodeToolsOpts.IdentComplReplaceIdentifier;
end else begin
ItemList.Clear;
exit;
end;
ctWordCompletion:
begin
ToggleReplaceWhole:=not CodeToolsOpts.IdentComplReplaceIdentifier;
ccSelection := '';
end;
@ -2240,8 +2243,6 @@ Begin
ctIdentCompletion:
begin
if not CodeToolsOpts.IdentComplReplaceIdentifier then
SourceEnd:=Editor.LogicalCaretXY;
if Manager.ActiveCompletionPlugin<>nil then
begin
Manager.ActiveCompletionPlugin.Complete(Value,SourceValue,
@ -2296,8 +2297,6 @@ Begin
// the completion is already in Value
begin
ccSelection := '';
if not CodeToolsOpts.IdentComplReplaceIdentifier then
SourceEnd:=Editor.LogicalCaretXY;
if Value<>'' then AWordCompletion.AddWord(Value);
end;