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