mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-23 05:45:00 +02:00
Fix Find-in-Files "Follow current doc" not working issue when absolute Default Directory set
This PR uses always current buffer's path in Find in Files dialog: When "Follow current doc." is checked, then use current path first. If that fails, fallback to the working directory as it was before. Fix #8045, close #10387
This commit is contained in:
parent
302bab894f
commit
0c16f87a18
@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <shlobj.h>
|
#include <shlwapi.h>
|
||||||
#include <uxtheme.h>
|
#include <uxtheme.h>
|
||||||
#include "FindReplaceDlg.h"
|
#include "FindReplaceDlg.h"
|
||||||
#include "ScintillaEditView.h"
|
#include "ScintillaEditView.h"
|
||||||
@ -1822,9 +1822,19 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
|||||||
|
|
||||||
if (findHistory._isFolderFollowDoc)
|
if (findHistory._isFolderFollowDoc)
|
||||||
{
|
{
|
||||||
NppParameters& nppParam = NppParameters::getInstance();
|
// Working directory depends on "Default Directory" preferences.
|
||||||
const TCHAR * dir = nppParam.getWorkingDir();
|
// It might be set to an absolute path value.
|
||||||
::SetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, dir);
|
// So try to get the current buffer's path first.
|
||||||
|
generic_string currPath;
|
||||||
|
const Buffer* buf = (*_ppEditView)->getCurrentBuffer();
|
||||||
|
if (!(buf->getStatus() & (DOC_UNNAMED | DOC_DELETED)))
|
||||||
|
{
|
||||||
|
currPath = buf->getFullPathName();
|
||||||
|
PathRemoveFileSpec(currPath);
|
||||||
|
}
|
||||||
|
if (currPath.empty() || !PathIsDirectory(currPath.c_str()))
|
||||||
|
currPath = NppParameters::getInstance().getWorkingDir();
|
||||||
|
::SetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, currPath.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user