mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-23 13:54:54 +02:00
Restore Folder as Workspace's latest selected item of last session on start up
Fix #8353
This commit is contained in:
parent
f3fce2de4a
commit
a2264e5b36
@ -3335,7 +3335,8 @@ void Notepad_plus::dropFiles(HDROP hdrop)
|
|||||||
else if (not isOldMode && (folderPaths.size() != 0 && filePaths.size() == 0)) // new mode && only folders
|
else if (not isOldMode && (folderPaths.size() != 0 && filePaths.size() == 0)) // new mode && only folders
|
||||||
{
|
{
|
||||||
// process new mode
|
// process new mode
|
||||||
launchFileBrowser(folderPaths);
|
generic_string emptyStr;
|
||||||
|
launchFileBrowser(folderPaths, emptyStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
::DragFinish(hdrop);
|
::DragFinish(hdrop);
|
||||||
@ -5990,7 +5991,7 @@ void Notepad_plus::launchAnsiCharPanel()
|
|||||||
_pAnsiCharPanel->display();
|
_pAnsiCharPanel->display();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notepad_plus::launchFileBrowser(const vector<generic_string> & folders, bool fromScratch)
|
void Notepad_plus::launchFileBrowser(const vector<generic_string> & folders, const generic_string& selectedItemPath, bool fromScratch)
|
||||||
{
|
{
|
||||||
if (!_pFileBrowser)
|
if (!_pFileBrowser)
|
||||||
{
|
{
|
||||||
@ -6042,6 +6043,7 @@ void Notepad_plus::launchFileBrowser(const vector<generic_string> & folders, boo
|
|||||||
}
|
}
|
||||||
|
|
||||||
_pFileBrowser->display();
|
_pFileBrowser->display();
|
||||||
|
_pFileBrowser->selectItemFromPath(selectedItemPath);
|
||||||
|
|
||||||
checkMenuItem(IDM_VIEW_FILEBROWSER, true);
|
checkMenuItem(IDM_VIEW_FILEBROWSER, true);
|
||||||
_toolBar.setCheck(IDM_VIEW_FILEBROWSER, true);
|
_toolBar.setCheck(IDM_VIEW_FILEBROWSER, true);
|
||||||
|
@ -607,7 +607,7 @@ private:
|
|||||||
void launchProjectPanel(int cmdID, ProjectPanel ** pProjPanel, int panelID);
|
void launchProjectPanel(int cmdID, ProjectPanel ** pProjPanel, int panelID);
|
||||||
void launchDocMap();
|
void launchDocMap();
|
||||||
void launchFunctionList();
|
void launchFunctionList();
|
||||||
void launchFileBrowser(const std::vector<generic_string> & folders, bool fromScratch = false);
|
void launchFileBrowser(const std::vector<generic_string> & folders, const generic_string& selectedItemPath, bool fromScratch = false);
|
||||||
void showAllQuotes() const;
|
void showAllQuotes() const;
|
||||||
static DWORD WINAPI threadTextPlayer(void *text2display);
|
static DWORD WINAPI threadTextPlayer(void *text2display);
|
||||||
static DWORD WINAPI threadTextTroller(void *params);
|
static DWORD WINAPI threadTextTroller(void *params);
|
||||||
|
@ -246,7 +246,8 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
|
|||||||
// To avoid dockable panel toggle problem.
|
// To avoid dockable panel toggle problem.
|
||||||
if (cmdLineParams->_openFoldersAsWorkspace)
|
if (cmdLineParams->_openFoldersAsWorkspace)
|
||||||
{
|
{
|
||||||
_notepad_plus_plus_core.launchFileBrowser(fns, true);
|
generic_string emptyStr;
|
||||||
|
_notepad_plus_plus_core.launchFileBrowser(fns, emptyStr, true);
|
||||||
}
|
}
|
||||||
::SendMessage(_hSelf, WM_ACTIVATE, WA_ACTIVE, 0);
|
::SendMessage(_hSelf, WM_ACTIVATE, WA_ACTIVE, 0);
|
||||||
|
|
||||||
|
@ -131,7 +131,8 @@ void Notepad_plus::command(int id)
|
|||||||
if (_pFileBrowser == nullptr) // first launch, check in params to open folders
|
if (_pFileBrowser == nullptr) // first launch, check in params to open folders
|
||||||
{
|
{
|
||||||
vector<generic_string> dummy;
|
vector<generic_string> dummy;
|
||||||
launchFileBrowser(dummy);
|
generic_string emptyStr;
|
||||||
|
launchFileBrowser(dummy, emptyStr);
|
||||||
if (_pFileBrowser != nullptr)
|
if (_pFileBrowser != nullptr)
|
||||||
{
|
{
|
||||||
checkMenuItem(IDM_VIEW_FILEBROWSER, true);
|
checkMenuItem(IDM_VIEW_FILEBROWSER, true);
|
||||||
@ -736,7 +737,7 @@ void Notepad_plus::command(int id)
|
|||||||
if (_pFileBrowser == nullptr) // first launch, check in params to open folders
|
if (_pFileBrowser == nullptr) // first launch, check in params to open folders
|
||||||
{
|
{
|
||||||
NppParameters& nppParam = NppParameters::getInstance();
|
NppParameters& nppParam = NppParameters::getInstance();
|
||||||
launchFileBrowser(nppParam.getFileBrowserRoots());
|
launchFileBrowser(nppParam.getFileBrowserRoots(), nppParam.getFileBrowserSelectedItemPath());
|
||||||
if (_pFileBrowser != nullptr)
|
if (_pFileBrowser != nullptr)
|
||||||
{
|
{
|
||||||
checkMenuItem(IDM_VIEW_FILEBROWSER, true);
|
checkMenuItem(IDM_VIEW_FILEBROWSER, true);
|
||||||
@ -756,7 +757,8 @@ void Notepad_plus::command(int id)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
vector<generic_string> dummy;
|
vector<generic_string> dummy;
|
||||||
launchFileBrowser(dummy);
|
generic_string emptyStr;
|
||||||
|
launchFileBrowser(dummy, emptyStr);
|
||||||
checkMenuItem(IDM_VIEW_FILEBROWSER, true);
|
checkMenuItem(IDM_VIEW_FILEBROWSER, true);
|
||||||
_toolBar.setCheck(IDM_VIEW_FILEBROWSER, true);
|
_toolBar.setCheck(IDM_VIEW_FILEBROWSER, true);
|
||||||
_pFileBrowser->setClosed(false);
|
_pFileBrowser->setClosed(false);
|
||||||
|
@ -2208,11 +2208,17 @@ void NppParameters::feedFileListParameters(TiXmlNode *node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NppParameters::feedProjectPanelsParameters(TiXmlNode *node)
|
void NppParameters::feedFileBrowserParameters(TiXmlNode *node)
|
||||||
{
|
{
|
||||||
TiXmlNode *fileBrowserRoot = node->FirstChildElement(TEXT("FileBrowser"));
|
TiXmlNode *fileBrowserRoot = node->FirstChildElement(TEXT("FileBrowser"));
|
||||||
if (!fileBrowserRoot) return;
|
if (!fileBrowserRoot) return;
|
||||||
|
|
||||||
|
const TCHAR *selectedItemPath = (fileBrowserRoot->ToElement())->Attribute(TEXT("latestSelectedItem"));
|
||||||
|
if (selectedItemPath)
|
||||||
|
{
|
||||||
|
_fileBrowserSelectedItemPath = selectedItemPath;
|
||||||
|
}
|
||||||
|
|
||||||
for (TiXmlNode *childNode = fileBrowserRoot->FirstChildElement(TEXT("root"));
|
for (TiXmlNode *childNode = fileBrowserRoot->FirstChildElement(TEXT("root"));
|
||||||
childNode;
|
childNode;
|
||||||
childNode = childNode->NextSibling(TEXT("root")) )
|
childNode = childNode->NextSibling(TEXT("root")) )
|
||||||
@ -2225,7 +2231,7 @@ void NppParameters::feedProjectPanelsParameters(TiXmlNode *node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NppParameters::feedFileBrowserParameters(TiXmlNode *node)
|
void NppParameters::feedProjectPanelsParameters(TiXmlNode *node)
|
||||||
{
|
{
|
||||||
TiXmlNode *projPanelRoot = node->FirstChildElement(TEXT("ProjectPanels"));
|
TiXmlNode *projPanelRoot = node->FirstChildElement(TEXT("ProjectPanels"));
|
||||||
if (!projPanelRoot) return;
|
if (!projPanelRoot) return;
|
||||||
|
@ -1546,6 +1546,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
const std::vector<generic_string> getFileBrowserRoots() const { return _fileBrowserRoot; };
|
const std::vector<generic_string> getFileBrowserRoots() const { return _fileBrowserRoot; };
|
||||||
|
generic_string getFileBrowserSelectedItemPath() const { return _fileBrowserSelectedItemPath; };
|
||||||
|
|
||||||
void setWorkSpaceFilePath(int i, const TCHAR *wsFile);
|
void setWorkSpaceFilePath(int i, const TCHAR *wsFile);
|
||||||
|
|
||||||
void setWorkingDir(const TCHAR * newPath);
|
void setWorkingDir(const TCHAR * newPath);
|
||||||
@ -1794,6 +1796,7 @@ private:
|
|||||||
generic_string _workSpaceFilePathes[3];
|
generic_string _workSpaceFilePathes[3];
|
||||||
|
|
||||||
std::vector<generic_string> _fileBrowserRoot;
|
std::vector<generic_string> _fileBrowserRoot;
|
||||||
|
generic_string _fileBrowserSelectedItemPath;
|
||||||
|
|
||||||
Accelerator *_pAccelerator;
|
Accelerator *_pAccelerator;
|
||||||
ScintillaAccelerator * _pScintAccelerator;
|
ScintillaAccelerator * _pScintAccelerator;
|
||||||
|
@ -383,21 +383,34 @@ void FileBrowser::initPopupMenus()
|
|||||||
::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, cmdHere.c_str());
|
::InsertMenu(_hFileMenu, 0, MF_BYCOMMAND, IDM_FILEBROWSER_CMDHERE, cmdHere.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileBrowser::selectCurrentEditingFile() const
|
bool FileBrowser::selectItemFromPath(const generic_string& itemPath) const
|
||||||
{
|
{
|
||||||
TCHAR currentDocPath[MAX_PATH] = { '0' };
|
if (itemPath.empty())
|
||||||
::SendMessage(_hParent, NPPM_GETFULLCURRENTPATH, MAX_PATH, reinterpret_cast<LPARAM>(currentDocPath));
|
return false;
|
||||||
generic_string rootFolderPath = currentDocPath;
|
|
||||||
|
size_t itemPathLen = itemPath.size();
|
||||||
|
|
||||||
for (const auto f : _folderUpdaters)
|
for (const auto f : _folderUpdaters)
|
||||||
{
|
{
|
||||||
if (isRelatedRootFolder(f->_rootFolder._rootPath, rootFolderPath))
|
if (isRelatedRootFolder(f->_rootFolder._rootPath, itemPath))
|
||||||
{
|
{
|
||||||
generic_string rootPath = f->_rootFolder._rootPath;
|
generic_string rootPath = f->_rootFolder._rootPath;
|
||||||
generic_string pathSuffix = rootFolderPath.substr(rootPath.size() + 1, rootFolderPath.size() - rootPath.size());
|
size_t rootPathLen = rootPath.size();
|
||||||
vector<generic_string> linarPathArray = split(pathSuffix, '\\');
|
if (rootPathLen > itemPathLen) // It should never happen
|
||||||
|
return false;
|
||||||
|
|
||||||
|
vector<generic_string> linarPathArray;
|
||||||
|
if (rootPathLen == itemPathLen)
|
||||||
|
{
|
||||||
|
// Do nothing and use empty linarPathArray
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
generic_string pathSuffix = itemPath.substr(rootPathLen + 1, itemPathLen - rootPathLen);
|
||||||
|
linarPathArray = split(pathSuffix, '\\');
|
||||||
|
}
|
||||||
HTREEITEM foundItem = findInTree(rootPath, nullptr, linarPathArray);
|
HTREEITEM foundItem = findInTree(rootPath, nullptr, linarPathArray);
|
||||||
|
|
||||||
if (foundItem)
|
if (foundItem)
|
||||||
{
|
{
|
||||||
_treeView.selectItem(foundItem);
|
_treeView.selectItem(foundItem);
|
||||||
@ -409,6 +422,15 @@ bool FileBrowser::selectCurrentEditingFile() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool FileBrowser::selectCurrentEditingFile() const
|
||||||
|
{
|
||||||
|
TCHAR currentDocPath[MAX_PATH] = { '0' };
|
||||||
|
::SendMessage(_hParent, NPPM_GETFULLCURRENTPATH, MAX_PATH, reinterpret_cast<LPARAM>(currentDocPath));
|
||||||
|
generic_string currentDocPathStr = currentDocPath;
|
||||||
|
|
||||||
|
return selectItemFromPath(currentDocPathStr);
|
||||||
|
}
|
||||||
|
|
||||||
BOOL FileBrowser::setImageList(int root_clean_id, int root_dirty_id, int open_node_id, int closed_node_id, int leaf_id)
|
BOOL FileBrowser::setImageList(int root_clean_id, int root_dirty_id, int open_node_id, int closed_node_id, int leaf_id)
|
||||||
{
|
{
|
||||||
HBITMAP hbmp;
|
HBITMAP hbmp;
|
||||||
@ -1227,7 +1249,11 @@ HTREEITEM FileBrowser::findInTree(const generic_string& rootPath, HTREEITEM node
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (linarPathArray.size() == 1)
|
if (linarPathArray.empty()) // nothing to search, return node
|
||||||
|
{
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
else if (linarPathArray.size() == 1)
|
||||||
{
|
{
|
||||||
// Search
|
// Search
|
||||||
return findChildNodeFromName(node, linarPathArray[0]);
|
return findChildNodeFromName(node, linarPathArray[0]);
|
||||||
|
@ -164,6 +164,8 @@ public:
|
|||||||
std::vector<generic_string> getRoots() const;
|
std::vector<generic_string> getRoots() const;
|
||||||
generic_string getSelectedItemPath() const;
|
generic_string getSelectedItemPath() const;
|
||||||
|
|
||||||
|
bool selectItemFromPath(const generic_string& itemPath) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HWND _hToolbarMenu = nullptr;
|
HWND _hToolbarMenu = nullptr;
|
||||||
|
|
||||||
@ -186,6 +188,7 @@ protected:
|
|||||||
|
|
||||||
BrowserNodeType getNodeType(HTREEITEM hItem);
|
BrowserNodeType getNodeType(HTREEITEM hItem);
|
||||||
void popupMenuCmd(int cmdID);
|
void popupMenuCmd(int cmdID);
|
||||||
|
|
||||||
bool selectCurrentEditingFile() const;
|
bool selectCurrentEditingFile() const;
|
||||||
|
|
||||||
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
virtual INT_PTR CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user