From 3dc847126b0a9835d4cdff7e4307f1d3c2ef226e Mon Sep 17 00:00:00 2001 From: mattias Date: Fri, 30 May 2014 15:52:04 +0000 Subject: [PATCH] IDE: open file: if in project search path, do not check if it is a symlink git-svn-id: trunk@45250 - --- ide/dialogprocs.pas | 48 +++++++++++++++++++-------------------- ide/environmentopts.pp | 13 +++++------ ide/sourcefilemanager.pas | 10 +++++++- 3 files changed, 39 insertions(+), 32 deletions(-) diff --git a/ide/dialogprocs.pas b/ide/dialogprocs.pas index c6b5ffe40d..0b1a4a1801 100644 --- a/ide/dialogprocs.pas +++ b/ide/dialogprocs.pas @@ -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; diff --git a/ide/environmentopts.pp b/ide/environmentopts.pp index 49ba5b722f..5c43bb9005 100644 --- a/ide/environmentopts.pp +++ b/ide/environmentopts.pp @@ -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; diff --git a/ide/sourcefilemanager.pas b/ide/sourcefilemanager.pas index b2d2285453..a8661205b9 100644 --- a/ide/sourcefilemanager.pas +++ b/ide/sourcefilemanager.pas @@ -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);