Fix current directory not applied bug after changing current directory option

Refresh the working directory when changing Follow current document preference.

Fix #10396, close #10426
This commit is contained in:
mere-human 2021-08-22 00:09:31 +03:00 committed by Don Ho
parent cd8e479ffa
commit d41b4e1645
3 changed files with 12 additions and 0 deletions

View File

@ -2671,6 +2671,15 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return TRUE;
}
case NPPM_INTERNAL_REFRESHWORKDIR:
{
const Buffer* buf = _pEditView->getCurrentBuffer();
generic_string path = buf ? buf->getFullPathName() : _T("");
PathRemoveFileSpec(path);
setWorkingDir(path.c_str());
return TRUE;
}
default:
{
if (message == WDN_NOTIFY)

View File

@ -2148,6 +2148,7 @@ INT_PTR CALLBACK DefaultDirectorySubDlg::run_dlgProc(UINT message, WPARAM wParam
{
case IDC_OPENSAVEDIR_FOLLOWCURRENT_RADIO:
nppGUI._openSaveDir = dir_followCurrent;
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_REFRESHWORKDIR, 0, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_OPENSAVEDIR_ALWAYSON_EDIT), false);
::EnableWindow(::GetDlgItem(_hSelf, IDD_OPENSAVEDIR_ALWAYSON_BROWSE_BUTTON), false);
return TRUE;
@ -2158,6 +2159,7 @@ INT_PTR CALLBACK DefaultDirectorySubDlg::run_dlgProc(UINT message, WPARAM wParam
return TRUE;
case IDC_OPENSAVEDIR_ALWAYSON_RADIO:
nppGUI._openSaveDir = dir_userDef;
::SendMessage(::GetParent(_hParent), NPPM_INTERNAL_REFRESHWORKDIR, 0, 0);
::EnableWindow(::GetDlgItem(_hSelf, IDC_OPENSAVEDIR_ALWAYSON_EDIT), true);
::EnableWindow(::GetDlgItem(_hSelf, IDD_OPENSAVEDIR_ALWAYSON_BROWSE_BUTTON), true);
return TRUE;

View File

@ -632,6 +632,7 @@
#define NPPM_INTERNAL_UPDATETEXTZONEPADDING (NOTEPADPLUS_USER_INTERNAL + 58)
#define NPPM_INTERNAL_REFRESHDARKMODE (NOTEPADPLUS_USER_INTERNAL + 59)
#define NPPM_INTERNAL_SCINTILLAFINDERCOPYPATHS (NOTEPADPLUS_USER_INTERNAL + 60)
#define NPPM_INTERNAL_REFRESHWORKDIR (NOTEPADPLUS_USER_INTERNAL + 61)
// See Notepad_plus_msgs.h
//#define NOTEPADPLUS_USER (WM_USER + 1000)