Forum > Editor

Nonexisting recent projects are removed form the list

(1/2) > >>

CM630:
I have the following problem:
When I try to open a nonexisting recent project it gets removed from the recent list.
The reason for the project being nonexistent is that it is stored on an unmounted network drive.
Is there a way to prevent the IDE from removing these projects?

GetMem:

--- Quote from: CM630 on January 04, 2022, 07:55:07 am ---I have the following problem:
When I try to open a nonexisting recent project it gets removed from the recent list.
The reason for the project being nonexistent is that it is stored on an unmounted network drive.
Is there a way to prevent the IDE from removing these projects?

--- End quote ---
1. Open $(LazarusDir)\IDE\MainBase.pas
2. Go to method DoOpenRecentFile
3. Uncomment the following two lines:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---//..{ if not FileExistsUTF8(AFilename) then begin   EnvironmentOptions.RemoveFromRecentOpenFiles(AFilename);}//..4. Rebuild IDE

Ideally one should add a new checkbox("Keep non existent recent project files in list")  to Tools->Environment->Files. When checked the EnvironmentOptions.RemoveFromRecentOpenFiles part of the code is skipped. Very easy to implement, but somehow I'm under the impression that it wouldn't be a very popular feature. Basically other then you no one would use it.

CM630:
That code does not seem to be executed when opening a project. I have even aded a message box, but it does not show:




--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TMainIDEBase.DoOpenRecentFile(AFilename: string);begin  ShowMessage ('Will open project');  if DoOpenEditorFile(AFilename,-1,-1,[ofAddToRecent])=mrOk then    UpdateRecentFilesEnv  else begin    // open failed    if not FileExistsUTF8(AFilename) then     begin      // file does not exist -> delete it from recent file list{      EnvironmentOptions.RemoveFromRecentOpenFiles(AFilename);      UpdateRecentFilesEnv;}    end;  end;end; 
Also, I have added some nonsense in the code, so when I received an error, I got sure that the mainbase.pas is really compiled.

Bart:
@CM630: Can you file a bugreport for the feature request to make the removal optional?
Please explain your use case (disconnected network share).
I don't think you are the only Lazarus user out there that might welcome such a feature.

Bart

Sieben:
I think the right place to look for this is OpenProject() in SourceFileManager.pas:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  if Assigned(aMenuItem) and (aMenuItem.Section=itmProjectRecentOpen) then  begin    // Hint holds the full filename, Caption may have a shortened form.    AFileName:=aMenuItem.Hint;    Assert(AFileName = ExpandFileNameUTF8(AFileName),'OpenProject: AFileName is not absolute.');    if MainIDE.DoOpenProjectFile(AFilename,[ofAddToRecent])=mrOk then begin      AddRecentProjectFile(AFilename);    end else begin      // open failed      if not FileExistsCached(AFilename) then begin        EnvironmentOptions.RemoveFromRecentProjectFiles(AFilename);      end else        AddRecentProjectFile(AFilename);    end;  end  else begin //...      

Navigation

[0] Message Index

[#] Next page

Go to full version