mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 20:59:06 +02:00
IDE: open file at cursor: show error message on fail
git-svn-id: trunk@56083 -
This commit is contained in:
parent
e05552a178
commit
61d4aa8258
@ -3824,7 +3824,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
until false;
|
until false;
|
||||||
Col:=p-PChar(Line)+1;
|
Col:=p-PChar(Line)+1;
|
||||||
writeln('TFindDeclarationTool.FindFileAtCursor Col=',Col,' CursorCol=',CursorPos.X,' Literal=',copy(Line,StartCol+1,p-StartP));
|
//writeln('TFindDeclarationTool.FindFileAtCursor Col=',Col,' CursorCol=',CursorPos.X,' Literal=',copy(Line,StartCol+1,p-StartP));
|
||||||
if (p>StartP) and (CursorPos.X>=StartCol) and (CursorPos.X<=Col) then begin
|
if (p>StartP) and (CursorPos.X>=StartCol) and (CursorPos.X<=Col) then begin
|
||||||
Literal:=copy(Line,StartCol+1,p-StartP);
|
Literal:=copy(Line,StartCol+1,p-StartP);
|
||||||
if not FilenameIsAbsolute(Literal) then
|
if not FilenameIsAbsolute(Literal) then
|
||||||
|
@ -4274,6 +4274,7 @@ resourcestring
|
|||||||
lisPkgMangThePackageFileNameInIsNotAValidLazarusPackageName = 'The package '
|
lisPkgMangThePackageFileNameInIsNotAValidLazarusPackageName = 'The package '
|
||||||
+'file name "%s" in%s"%s" is not a valid Lazarus package name.';
|
+'file name "%s" in%s"%s" is not a valid Lazarus package name.';
|
||||||
lisPkgMangFileNotFound = 'File "%s" not found.';
|
lisPkgMangFileNotFound = 'File "%s" not found.';
|
||||||
|
lisOpenFileAtCursor = 'Open file at cursor';
|
||||||
lisPkgMangErrorReadingPackage = 'Error Reading Package';
|
lisPkgMangErrorReadingPackage = 'Error Reading Package';
|
||||||
lisPkgUnableToReadPackageFileError = 'Unable to read package file "%s".%sError: %s';
|
lisPkgUnableToReadPackageFileError = 'Unable to read package file "%s".%sError: %s';
|
||||||
lisPkgMangFilenameDiffersFromPackagename = 'Filename differs from Packagename';
|
lisPkgMangFilenameDiffersFromPackagename = 'Filename differs from Packagename';
|
||||||
|
@ -1535,6 +1535,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TFileOpener.OpenFileAtCursor: TModalResult;
|
function TFileOpener.OpenFileAtCursor: TModalResult;
|
||||||
|
|
||||||
|
function ShowNotFound(aFilename: string): TModalResult;
|
||||||
|
begin
|
||||||
|
Result:=mrCancel;
|
||||||
|
if aFilename<>'' then
|
||||||
|
IDEMessageDialog(lisOpenFileAtCursor, lisFileNotFound+':'#13+aFileName,
|
||||||
|
mtError, [mbOk]);
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
Found: Boolean;
|
Found: Boolean;
|
||||||
BaseDir: String;
|
BaseDir: String;
|
||||||
@ -1560,7 +1569,7 @@ begin
|
|||||||
if FileExistsCached(FFileName) then
|
if FileExistsCached(FFileName) then
|
||||||
Found:=true
|
Found:=true
|
||||||
else
|
else
|
||||||
exit;
|
exit(ShowNotFound(FFileName));
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1569,8 +1578,11 @@ begin
|
|||||||
if CodeToolBoss.FindFileAtCursor(FActiveSrcEdit.CodeBuffer,
|
if CodeToolBoss.FindFileAtCursor(FActiveSrcEdit.CodeBuffer,
|
||||||
Edit.LogicalCaretXY.X,Edit.LogicalCaretXY.Y,FoundType,FFileName) then
|
Edit.LogicalCaretXY.X,Edit.LogicalCaretXY.Y,FoundType,FFileName) then
|
||||||
Found:=true
|
Found:=true
|
||||||
else
|
else begin
|
||||||
exit;
|
FFileName:=FActiveSrcEdit.EditorComponent.GetWordAtRowCol(
|
||||||
|
FActiveSrcEdit.EditorComponent.LogicalCaretXY);
|
||||||
|
exit(ShowNotFound(FFileName));
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if not Found then begin
|
if not Found then begin
|
||||||
@ -1582,7 +1594,7 @@ begin
|
|||||||
if FileExistsCached(FFileName) then
|
if FileExistsCached(FFileName) then
|
||||||
Found:=true
|
Found:=true
|
||||||
else
|
else
|
||||||
exit;
|
exit(ShowNotFound(FFileName));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if FIsIncludeDirective then
|
if FIsIncludeDirective then
|
||||||
@ -1655,7 +1667,8 @@ begin
|
|||||||
InputHistories.SetFileDialogSettingsInitialDir(ExtractFilePath(FFileName));
|
InputHistories.SetFileDialogSettingsInitialDir(ExtractFilePath(FFileName));
|
||||||
FUseWindowID:=False;
|
FUseWindowID:=False;
|
||||||
Result:=OpenEditorFile(-1, -1, nil, [ofAddToRecent]);
|
Result:=OpenEditorFile(-1, -1, nil, [ofAddToRecent]);
|
||||||
end;
|
end else
|
||||||
|
exit(ShowNotFound(FFileName));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFileOpener.OpenMainUnit: TModalResult;
|
function TFileOpener.OpenMainUnit: TModalResult;
|
||||||
|
Loading…
Reference in New Issue
Block a user