Recent

Author Topic: Nonexisting recent projects are removed form the list  (Read 3067 times)

CM630

  • Hero Member
  • *****
  • Posts: 988
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Nonexisting recent projects are removed form the list
« 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?
Лазар 2,2,0 32 bit; FPC3,2,2; rev: Lazarus_2_2_0 on W10 64bit.

GetMem

  • Hero Member
  • *****
  • Posts: 3741
Re: Nonexisting recent projects are removed form the list
« Reply #1 on: January 04, 2022, 09:33:36 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?
1. Open $(LazarusDir)\IDE\MainBase.pas
2. Go to method DoOpenRecentFile
3. Uncomment the following two lines:
Code: Pascal  [Select][+][-]
  1. //..
  2. { if not FileExistsUTF8(AFilename) then begin
  3.    EnvironmentOptions.RemoveFromRecentOpenFiles(AFilename);}
  4. //..
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

  • Hero Member
  • *****
  • Posts: 988
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Nonexisting recent projects are removed form the list
« Reply #2 on: January 04, 2022, 01:01:30 pm »
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  [Select][+][-]
  1. procedure TMainIDEBase.DoOpenRecentFile(AFilename: string);
  2. begin
  3.   ShowMessage ('Will open project');
  4.   if DoOpenEditorFile(AFilename,-1,-1,[ofAddToRecent])=mrOk then
  5.     UpdateRecentFilesEnv
  6.   else begin
  7.     // open failed
  8.     if not FileExistsUTF8(AFilename) then
  9.     begin
  10.       // file does not exist -> delete it from recent file list
  11. {      EnvironmentOptions.RemoveFromRecentOpenFiles(AFilename);
  12.       UpdateRecentFilesEnv;}
  13.     end;
  14.   end;
  15. end;
  16.  

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.
Лазар 2,2,0 32 bit; FPC3,2,2; rev: Lazarus_2_2_0 on W10 64bit.

Bart

  • Hero Member
  • *****
  • Posts: 4689
    • Bart en Mariska's Webstek
Re: Nonexisting recent projects are removed form the list
« Reply #3 on: January 04, 2022, 01:32:39 pm »
@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

  • Sr. Member
  • ****
  • Posts: 299
Re: Nonexisting recent projects are removed form the list
« Reply #4 on: January 04, 2022, 01:38:14 pm »
I think the right place to look for this is OpenProject() in SourceFileManager.pas:

Code: Pascal  [Select][+][-]
  1.   if Assigned(aMenuItem) and (aMenuItem.Section=itmProjectRecentOpen) then
  2.   begin
  3.     // Hint holds the full filename, Caption may have a shortened form.
  4.     AFileName:=aMenuItem.Hint;
  5.     Assert(AFileName = ExpandFileNameUTF8(AFileName),'OpenProject: AFileName is not absolute.');
  6.     if MainIDE.DoOpenProjectFile(AFilename,[ofAddToRecent])=mrOk then begin
  7.       AddRecentProjectFile(AFilename);
  8.     end else begin
  9.       // open failed
  10.       if not FileExistsCached(AFilename) then begin
  11.         EnvironmentOptions.RemoveFromRecentProjectFiles(AFilename);
  12.       end else
  13.         AddRecentProjectFile(AFilename);
  14.     end;
  15.   end
  16.   else begin //...      

Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 7885
  • Debugger - SynEdit - and more
    • wiki
Re: Nonexisting recent projects are removed form the list
« Reply #5 on: January 04, 2022, 02:04:51 pm »
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.

Actually, you can almost count me in... Except, I moved to a diff solution.

I have a "project group" with all my "commonly used projects". => So I no longer depend on "recent projects".
However, I have projects on that list that do temporarily disappear. (They only exist on some branches in my version control).

"project group" also have a check for non-existence.
But with "open last group on IDE start", those are kept in the list (and displayed strike-through).

CM630

  • Hero Member
  • *****
  • Posts: 988
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Nonexisting recent projects are removed form the list
« Reply #6 on: January 04, 2022, 03:10:44 pm »
Thanks to all of you,
I have created a feature request ticket: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/39530
Лазар 2,2,0 32 bit; FPC3,2,2; rev: Lazarus_2_2_0 on W10 64bit.

 

TinyPortal © 2005-2018