IDE: open file at cursor: show error message on fail

git-svn-id: branches/fixes_1_8@56084 -
This commit is contained in:
mattias 2017-10-16 14:07:07 +00:00
parent c1a318b0ed
commit 0f7b690083
3 changed files with 20 additions and 6 deletions

View File

@ -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

View File

@ -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';

View File

@ -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;