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