-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remember directory for "remember last used directory" setting across sessions: fix issue 11326 and others #13887
Remember directory for "remember last used directory" setting across sessions: fix issue 11326 and others #13887
Conversation
previously config.xml did not remember the last used directory if "Remember last used directory" was chosen for the Default Directory setting.
👍 Allow me one question. (In the "Search Engine" page - the custom engine is also remembered if you select one of the pre-defined options). Thank you for your time and work. |
I can totally understand where you're coming from, but I don't think the
added complexity of both source code and config.xml would be worth it.
We'll see what Don Ho says, but my feeling is that minimizing the change to
the source gives this PR the best chance of success.
…On Wed, Jul 12, 2023, 12:41 PM Yaron10 ***@***.***> wrote:
@molsonkiko <https://github.com/molsonkiko>,
👍
Great.
It seems to be working like a charm.
Allow me one question.
Currently (master) if you set a custom-fixed folder (i.e. the third option
in the "Default Directory" page), and then select one of the other two
options - the fixed folder is remembered across sessions.
With this PR, if you set a fixed folder and then select "Last Used
Directory" - the fixed folder is NOT remembered.
Wouldn't it be much better to remember both? Isn't it worth the extra code
and a separate field in config.xml?
(In the "Search Engine" page - the custom engine is also remembered if you
select one of the pre-defined options).
Thank you for your time and work.
—
Reply to this email directly, view it on GitHub
<#13887 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALAQAI2M5ML3OV4RPXMLNQDXP34XFANCNFSM6AAAAAA2G3PPCM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
My favorite PRs are those which reduce and optimize the code. But I do respect your opinion. |
@Yaron10 I still want to wait for Don Ho's opinion before I change the PR any more though. |
👍 |
Without talking about the implementation, do you guys think "Remember last used directory" should be through the sessions? |
This makes sense to me. |
It seems "straightforward" to the users that "Remember last used directory" is through the sessions. However, if "Default Open/Save file Directory" switch off from "Remember last used directory" to "Follow Current document" or to "Customized", and after some uses (open or save) it's switched back to "Remember last used directory" - what should be the value of "Remember last used directory"? |
I'm happy to try to implement whatever people decide is the most sensible way to implement this setting. One thing that might help me with this task would be a better understanding of what |
Why not use the current (master) behavior? - That is: when the user is selecting "Follow Current document" or "Custom", that folder is assigned to "Last used directory".
I hope @donho would be kind enough to help you with that. |
You can see them in the Files changed tab that shows the patch. ::ExpandEnvironmentStrings(_nppGUI._defaultDir, _nppGUI._defaultDirExp, MAX_PATH);
Look for yourself at ExpandEnvironmentStringsW function which I used as a guide. |
By hacking
I will take care of the fix myself. |
This issue has been opened for years. I hope you understand. |
I'm not aware of it indeed. |
Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider the suggestion.
Now the last used directory remembered independently from the current directory and the default directory. Changing the default directory or changing the current directory has no impact on last used directory anymore. Both are also now in config.xml
My most recent commit makes "last used directory" independent of the current file's directory and the default directory, as requested. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Following the suggestions
- Test your code to prevent PR from the regression.
Good to know! Thanks for pointing that out, @rdipardo.
…On Wed, Jul 19, 2023, 12:00 PM rdipardo ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In PowerEditor/src/Parameters.h
<#13887 (comment)>
:
> @@ -923,6 +924,8 @@ struct NppGUI final
DarkModeConf _darkmode;
LargeFileRestriction _largeFileRestriction;
+
+ TCHAR _lastUsedDir[MAX_PATH];
By putting _lastUsedDir in the middle of the struct, I'm forcing every
plugin that interacts with that struct to make a bugfix patch [...]
Adding a new member in *any* position is already a breaking change. If a
plugin allocates insufficient memory for the bigger struct, the result
will be an out-of-bounds write, leading to memory corruption if not a crash
—
Reply to this email directly, view it on GitHub
<#13887 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALAQAI4SGOCROPF3E64SMOTXRAVFZANCNFSM6AAAAAA2G3PPCM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide the reason for removing params.setWorkingDir(_events->getLastUsedFolder().c_str());
.
If there's no valid reason to remove it, restore it.
PowerEditor/src/WinControls/OpenSaveFileDialog/CustomFileDialog.cpp
Outdated
Show resolved
Hide resolved
Thank you for your patient review and guidance. 👍 Thank you for your work. 👍 Windows saves applications' last used folder. I've just tested the new commit(s) here, and encountered what @alankilborn described in #11326 (comment):
STR: Use the binary of the latest commit here. Result: Should the basic approach in this PR be re-considered? In the current master, when the user is selecting "Follow Current document" or "Custom", that folder is assigned to "Last used directory". This is NOT the behavior with this PR. I think that either result is legit. |
My opinion is, let's keep the current implementation. Because just we cannot guarantee the Windows' behaviour is always unchanged. |
Good point. Also:
I didn't quite understand that. |
STR: Result: |
It does seem like if I shut down Notepad++ with no config.xml (so NPP has to create a new config.xml), it initially behaves weirdly with |
Thank you for looking into it. |
@Yaron10
|
@Yaron10 |
Thank you for your work. 👍
Tested with a fresh portable NPP. I suppose you've managed to reproduce it, correct? |
Thank you for your kind words. I appreciate it. 👍 @donho is the one who truly deserves many thanks & flowers for his on-going work on Notepad++, and for creating "a good open-source community". |
Would fix #11326
Would fix #10901
Would fix #4961
Would fix #4119
Previously config.xml did not remember the last used directory if "Remember last used directory" was chosen for the Default Directory setting. This meant that the last directory used for the
Open
/Save As
/Rename
forms was only tracked during the session, and was forgotten when the user quit Notepad++.To test:
foo
,bar
, andbaz
)Default Directory
setting toRemember last used directory
Open
to open a file in directoryfoo
.bar
.Open
,Save As
, orRename
forms. The starting directory should befoo
, because that was the last used directory in the previous session.bar
file, set theDefault Directory
setting tobaz
using the text box.Open
/Save As
/Rename
forms open in directorybaz
even when the current directory isbar
orfoo
.bar
.Default Directory
setting back toRemember last used directory
.Open
/Save As
/Rename
forms open in directorybaz
because that was the last used directory.Default Directory
setting toFollow current document
.foo
.Open
/Save As
/Rename
forms all open in directoryfoo
.Default Directory
setting toRemember last used directory
.bar
.Open
/Save As
/Rename
forms open in directoryfoo
because that was the last used directory.Open
/Save As
/Rename
forms open in directoryfoo
because that was the last used directory in the previous session.Comments
Arguably it is somewhat undesirable that changing from
Remember last used directory
toFollow current document
and then back toRemember last used directory
causes forgetting of the directory that was chosen before the first change, but arguably this makes perfect sense becauseRemember last used directory
is doing exactly what it claims to do, and remembering whatever directory was last chosen (whether implicitly or explicitly) by the user.