mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 16:36:01 +02:00
automatic identifier completion does not longer jump to errors
git-svn-id: trunk@7514 -
This commit is contained in:
parent
abd1617411
commit
0b9be2f264
15
ide/main.pp
15
ide/main.pp
@ -314,7 +314,7 @@ type
|
||||
procedure OnSrcNotebookFileClose(Sender: TObject);
|
||||
procedure OnSrcNotebookFindDeclaration(Sender: TObject);
|
||||
procedure OnSrcNotebookInitIdentCompletion(Sender: TObject;
|
||||
var Handled, Abort: boolean);
|
||||
JumpToError: boolean; out Handled, Abort: boolean);
|
||||
procedure OnSrcNotebookJumpToHistoryPoint(var NewCaretXY: TPoint;
|
||||
var NewTopLine, NewPageIndex: integer; JumpAction: TJumpHistoryAction);
|
||||
procedure OnSrcNotebookMovingPage(Sender: TObject;
|
||||
@ -730,7 +730,7 @@ type
|
||||
procedure DoFindDeclarationAtCursor;
|
||||
procedure DoFindDeclarationAtCaret(const LogCaretXY: TPoint);
|
||||
function DoFindRenameIdentifier(Rename: boolean): TModalResult;
|
||||
function DoInitIdentCompletion: boolean;
|
||||
function DoInitIdentCompletion(JumpToError: boolean): boolean;
|
||||
procedure DoCompleteCodeAtCursor;
|
||||
procedure DoExtractProcFromSelection;
|
||||
function DoCheckSyntax: TModalResult;
|
||||
@ -2152,10 +2152,10 @@ begin
|
||||
end;
|
||||
|
||||
procedure TMainIDE.OnSrcNotebookInitIdentCompletion(Sender: TObject;
|
||||
var Handled, Abort: boolean);
|
||||
JumpToError: boolean; out Handled, Abort: boolean);
|
||||
begin
|
||||
Handled:=true;
|
||||
Abort:=not DoInitIdentCompletion;
|
||||
Abort:=not DoInitIdentCompletion(JumpToError);
|
||||
end;
|
||||
|
||||
Procedure TMainIDE.OnSrcNotebookSaveAll(Sender: TObject);
|
||||
@ -10306,9 +10306,9 @@ begin
|
||||
end;
|
||||
|
||||
{-------------------------------------------------------------------------------
|
||||
function TMainIDE.DoInitIdentCompletion: boolean;
|
||||
function TMainIDE.DoInitIdentCompletion(JumpToError: boolean): boolean;
|
||||
-------------------------------------------------------------------------------}
|
||||
function TMainIDE.DoInitIdentCompletion: boolean;
|
||||
function TMainIDE.DoInitIdentCompletion(JumpToError: boolean): boolean;
|
||||
var
|
||||
ActiveSrcEdit: TSourceEditor;
|
||||
ActiveUnitInfo: TUnitInfo;
|
||||
@ -10324,7 +10324,8 @@ begin
|
||||
Result:=CodeToolBoss.GatherIdentifiers(ActiveUnitInfo.Source,
|
||||
LogCaretXY.X,LogCaretXY.Y);
|
||||
if not Result then begin
|
||||
DoJumpToCodeToolBossError;
|
||||
if JumpToError then
|
||||
DoJumpToCodeToolBossError;
|
||||
exit;
|
||||
end;
|
||||
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TMainIDE.DoInitIdentCompletion B');{$ENDIF}
|
||||
|
@ -188,7 +188,7 @@ type
|
||||
procedure SetExecutionLine(NewLine: integer);
|
||||
procedure OnCodeBufferChanged(Sender: TSourceLog;
|
||||
SrcLogEntry: TSourceLogEntry);
|
||||
procedure StartIdentCompletion;
|
||||
procedure StartIdentCompletion(JumpToError: boolean);
|
||||
|
||||
procedure LinesInserted(sender: TObject; FirstLine,Count: Integer);
|
||||
procedure LinesDeleted(sender: TObject; FirstLine,Count: Integer);
|
||||
@ -320,8 +320,8 @@ type
|
||||
OldPageIndex, NewPageIndex: integer) of object;
|
||||
TOnShowHintForSource = procedure(SrcEdit: TSourceEditor; ClientPos: TPoint;
|
||||
CaretPos: TPoint) of object;
|
||||
TOnInitIdentCompletion = procedure(Sender: TObject;
|
||||
var Handled, Abort: boolean) of object;
|
||||
TOnInitIdentCompletion = procedure(Sender: TObject; JumpToError: boolean;
|
||||
out Handled, Abort: boolean) of object;
|
||||
TSrcEditPopupMenuEvent = procedure(AddMenuItemProc: TAddMenuItemProc
|
||||
) of object;
|
||||
|
||||
@ -397,6 +397,7 @@ type
|
||||
FCodeTemplateModul: TSynEditAutoComplete;
|
||||
fCustomPopupMenuItems: TList;
|
||||
fContextPopupMenuItems: TList;
|
||||
fIdentCompletionJumpToError: boolean;
|
||||
FIncrementalSearchPos: TPoint; // last set position
|
||||
fIncrementalSearchStartPos: TPoint; // position where to start searching
|
||||
fIncrementalSearchCancelPos: TPoint;// position where to jump on cancel
|
||||
@ -1180,7 +1181,7 @@ Begin
|
||||
FindHelpForSourceAtCursor;
|
||||
|
||||
ecIdentCompletion :
|
||||
StartIdentCompletion;
|
||||
StartIdentCompletion(true);
|
||||
|
||||
ecWordCompletion :
|
||||
if not TCustomSynEdit(Sender).ReadOnly then begin
|
||||
@ -1911,32 +1912,33 @@ writeln('[TSourceEditor.OnCodeBufferChanged] A ',FIgnoreCodeBufferLock,' ',SrcLo
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TSourceEditor.StartIdentCompletion;
|
||||
procedure TSourceEditor.StartIdentCompletion(JumpToError: boolean);
|
||||
var
|
||||
I: Integer;
|
||||
P: TPoint;
|
||||
TextS, TextS2: String;
|
||||
LogCaret: TPoint;
|
||||
begin
|
||||
debugln('TSourceEditor.StartIdentCompletion');
|
||||
if not FEditor.ReadOnly then begin
|
||||
CurrentCompletionType:=ctIdentCompletion;
|
||||
TextS := FEditor.LineText;
|
||||
LogCaret:=FEditor.LogicalCaretXY;
|
||||
i := LogCaret.X - 1;
|
||||
if i > length(TextS) then
|
||||
TextS2 := ''
|
||||
else begin
|
||||
while (i > 0) and (TextS[i] in ['a'..'z','A'..'Z','0'..'9','_']) do
|
||||
dec(i);
|
||||
TextS2 := Trim(copy(TextS, i + 1, LogCaret.X - i - 1));
|
||||
end;
|
||||
with FEditor do
|
||||
P := ClientToScreen(Point(CaretXPix - length(TextS2)*CharWidth
|
||||
,CaretYPix + LineHeight));
|
||||
aCompletion.Editor:=FEditor;
|
||||
aCompletion.Execute(TextS2,P.X,P.Y);
|
||||
//debugln('TSourceEditor.StartIdentCompletion');
|
||||
if FEditor.ReadOnly then exit;
|
||||
SourceNoteBook.fIdentCompletionJumpToError:=JumpToError;
|
||||
|
||||
CurrentCompletionType:=ctIdentCompletion;
|
||||
TextS := FEditor.LineText;
|
||||
LogCaret:=FEditor.LogicalCaretXY;
|
||||
i := LogCaret.X - 1;
|
||||
if i > length(TextS) then
|
||||
TextS2 := ''
|
||||
else begin
|
||||
while (i > 0) and (TextS[i] in ['a'..'z','A'..'Z','0'..'9','_']) do
|
||||
dec(i);
|
||||
TextS2 := Trim(copy(TextS, i + 1, LogCaret.X - i - 1));
|
||||
end;
|
||||
with FEditor do
|
||||
P := ClientToScreen(Point(CaretXPix - length(TextS2)*CharWidth
|
||||
,CaretYPix + LineHeight));
|
||||
aCompletion.Editor:=FEditor;
|
||||
aCompletion.Execute(TextS2,P.X,P.Y);
|
||||
end;
|
||||
|
||||
procedure TSourceEditor.IncreaseIgnoreCodeBufferLock;
|
||||
@ -2525,7 +2527,7 @@ begin
|
||||
IdentCompletionTimer.Enabled:=false;
|
||||
IdentCompletionTimer.AutoEnabled:=false;
|
||||
TempEditor:=GetActiveSE;
|
||||
if TempEditor<>nil then TempEditor.StartIdentCompletion;
|
||||
if TempEditor<>nil then TempEditor.StartIdentCompletion(false);
|
||||
end;
|
||||
|
||||
procedure TSourceNotebook.OnCodeTemplateTokenNotFound(Sender: TObject;
|
||||
@ -2683,7 +2685,7 @@ var
|
||||
begin
|
||||
Prefix := CurCompletionControl.CurrentString;
|
||||
if Assigned(OnInitIdentCompletion) then begin
|
||||
OnInitIdentCompletion(Self,Handled,Abort);
|
||||
OnInitIdentCompletion(Self,fIdentCompletionJumpToError,Handled,Abort);
|
||||
if Handled then begin
|
||||
if Abort then exit;
|
||||
// add one entry per item
|
||||
|
Loading…
Reference in New Issue
Block a user