mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-04 00:20:47 +02:00
IDE: open file: if in project search path, do not check if it is a symlink
git-svn-id: trunk@45250 -
This commit is contained in:
parent
67dd475567
commit
3dc847126b
@ -37,8 +37,8 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Dialogs, FileProcs,
|
||||
FileUtil, LazFileUtils, Laz2_XMLCfg, lazutf8classes, CodeToolsConfig,
|
||||
CodeCache, CodeToolManager, AVL_Tree, LazIDEIntf, IDEProcs,
|
||||
FileUtil, LazFileUtils, Laz2_XMLCfg, lazutf8classes, LazFileCache,
|
||||
CodeToolsConfig, CodeCache, CodeToolManager, AVL_Tree, LazIDEIntf, IDEProcs,
|
||||
LazarusIDEStrConsts, IDEDialogs;
|
||||
|
||||
type
|
||||
@ -89,7 +89,7 @@ function CheckCreatingFile(const AFilename: string;
|
||||
): TModalResult;
|
||||
function CheckFileIsWritable(const Filename: string;
|
||||
ErrorButtons: TMsgDlgButtons): TModalResult;
|
||||
function ChooseSymlink(var Filename: string): TModalResult;
|
||||
function ChooseSymlink(var Filename: string; AskOnSymlink: boolean): TModalResult;
|
||||
function CreateSymlinkInteractive(const LinkFilename, TargetFilename: string;
|
||||
ErrorButtons: TMsgDlgButtons): TModalResult;
|
||||
function ForceDirectoryInteractive(Directory: string;
|
||||
@ -506,32 +506,32 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function ChooseSymlink(var Filename: string): TModalResult;
|
||||
function ChooseSymlink(var Filename: string; AskOnSymlink: boolean
|
||||
): TModalResult;
|
||||
var
|
||||
TargetFilename: String;
|
||||
begin
|
||||
if not FileExistsUTF8(Filename) then exit(mrOk);
|
||||
Result:=mrCancel;
|
||||
try
|
||||
TargetFilename:=ReadAllLinks(Filename,true);
|
||||
if TargetFilename<>Filename then begin
|
||||
case IDEQuestionDialog(lisFileIsSymlink,
|
||||
Format(lisTheFileIsASymlinkOpenInstead,
|
||||
['"', Filename, '"', LineEnding, LineEnding, '"', TargetFilename, '"']),
|
||||
mtConfirmation, [mbYes, lisOpenTarget, mbNo, lisOpenSymlink, mbCancel])
|
||||
of
|
||||
mrYes: Filename:=TargetFilename;
|
||||
mrNo: ;
|
||||
else exit;
|
||||
end;
|
||||
end;
|
||||
Result:=mrOk;
|
||||
except
|
||||
on E: Exception do begin
|
||||
IDEMessageDialog(lisFileLinkError,
|
||||
E.Message,mtError,[mbCancel]);
|
||||
if not FileExistsCached(Filename) then
|
||||
exit(mrOk); // no symlink to choose
|
||||
TargetFilename:=GetPhysicalFilenameCached(Filename,false);
|
||||
if TargetFilename=Filename then begin
|
||||
// no symlink to choose
|
||||
end else if not AskOnSymlink then begin
|
||||
// choose physical file
|
||||
Filename:=TargetFilename;
|
||||
end else begin
|
||||
// ask which filename to use
|
||||
case IDEQuestionDialog(lisFileIsSymlink,
|
||||
Format(lisTheFileIsASymlinkOpenInstead,
|
||||
['"', Filename, '"', LineEnding, LineEnding, '"', TargetFilename, '"']),
|
||||
mtConfirmation, [mbYes, lisOpenTarget, mbNo, lisOpenSymlink, mbCancel])
|
||||
of
|
||||
mrYes: Filename:=TargetFilename;
|
||||
mrNo: ;
|
||||
else exit(mrCancel);
|
||||
end;
|
||||
end;
|
||||
Result:=mrOk;
|
||||
end;
|
||||
|
||||
function CreateSymlinkInteractive(const LinkFilename, TargetFilename: string;
|
||||
|
@ -287,7 +287,6 @@ type
|
||||
FAutoSaveProject: boolean;
|
||||
FAutoSaveIntervalInSecs: integer;
|
||||
FLastSavedProjectFile: string;
|
||||
FAskSaveSessionOnly: boolean;
|
||||
|
||||
// window layout
|
||||
FIDEDialogLayoutList: TIDEDialogLayoutList;
|
||||
@ -338,6 +337,7 @@ type
|
||||
FPackageEditorShowDirHierarchy: boolean;
|
||||
|
||||
// hints
|
||||
FAskSaveSessionOnly: boolean;
|
||||
FCheckDiskChangesWithLoading: boolean;
|
||||
FShowHintsForComponentPalette: boolean;
|
||||
FShowHintsForMainSpeedButtons: boolean;
|
||||
@ -349,6 +349,8 @@ type
|
||||
FMsgViewShowTranslations: boolean;
|
||||
FMsgViewFilenameStyle: TMsgWndFileNameStyle;
|
||||
fMsgViewColors: array[TMsgWndColor] of TColor;
|
||||
FShowCompileDialog: Boolean; // show dialog during compile
|
||||
FAutoCloseCompileDialog: Boolean; // auto close dialog after succesed compile
|
||||
|
||||
// compiler + debugger + lazarus files
|
||||
FParseValues: array[TEnvOptParseType] of TParseString;
|
||||
@ -356,6 +358,7 @@ type
|
||||
FCompilerFileHistory: TStringList;
|
||||
FFPCSourceDirHistory: TStringList;
|
||||
FMakeFileHistory: TStringList;
|
||||
FTestBuildDirHistory: TStringList;
|
||||
FCompilerMessagesFileHistory: TStringList;
|
||||
FBuildMatrixOptions: TBuildMatrixOptions;
|
||||
FUseBuildModes: Boolean;
|
||||
@ -371,9 +374,6 @@ type
|
||||
FDebuggerFileHistory: TStringList; // per debugger class
|
||||
FDebuggerProperties: TStringList; // per debugger class
|
||||
FDebuggerShowStopMessage: Boolean;
|
||||
FShowCompileDialog: Boolean; // show dialog during compile
|
||||
FAutoCloseCompileDialog: Boolean; // auto close dialog after succesed compile
|
||||
FTestBuildDirHistory: TStringList;
|
||||
FDebuggerEventLogClearOnRun: Boolean;
|
||||
FDebuggerEventLogCheckLineLimit: Boolean;
|
||||
FDebuggerEventLogLineLimit: Integer;
|
||||
@ -395,6 +395,8 @@ type
|
||||
FRecentPackageFiles: TStringList;
|
||||
FMaxRecentPackageFiles: integer;
|
||||
FOpenLastProjectAtStart: boolean;
|
||||
// Prevent repopulating Recent project files menu with example projects if it was already cleared up.
|
||||
FAlreadyPopulatedRecentFiles : Boolean;
|
||||
|
||||
// backup
|
||||
FBackupInfoProjectFiles: TBackupInfo;
|
||||
@ -423,9 +425,6 @@ type
|
||||
FNewUnitTemplate: string;
|
||||
FFileDialogFilter: string;
|
||||
|
||||
// Prevent repopulating Recent project files menu with example projects if it was already cleared up.
|
||||
FAlreadyPopulatedRecentFiles : Boolean;
|
||||
|
||||
function GetCompilerFilename: string;
|
||||
function GetCompilerMessagesFilename: string;
|
||||
function GetDebuggerEventLogColors(AIndex: TDBGEventType): TDebuggerEventLogColor;
|
||||
|
@ -1320,6 +1320,7 @@ var
|
||||
Reverting: Boolean;
|
||||
CanAbort: boolean;
|
||||
NewEditorInfo: TUnitEditorInfo;
|
||||
SearchPath: String;
|
||||
|
||||
function OpenResource: TModalResult;
|
||||
var
|
||||
@ -1455,7 +1456,14 @@ begin
|
||||
end;
|
||||
|
||||
// check if symlink and ask user if the real file should be opened instead
|
||||
ChooseSymlink(AFilename);
|
||||
if FilenameIsAbsolute(AFileName) then begin
|
||||
SearchPath:=CodeToolBoss.GetCompleteSrcPathForDirectory('');
|
||||
if SearchDirectoryInSearchPath(SearchPath,ExtractFilePath(AFileName))<1 then
|
||||
begin
|
||||
// the file is not in the project search path => check if it is a symlink
|
||||
ChooseSymlink(AFilename,true);
|
||||
end;
|
||||
end;
|
||||
|
||||
FilenameNoPath:=ExtractFilename(AFilename);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user