Skip to content

Commit

Permalink
Add more workaround to ensure handling the correct document
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobo1 committed Aug 25, 2018
1 parent 54e8e40 commit 3d0d054
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
25 changes: 24 additions & 1 deletion src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,37 @@ extern "C" NPPAUTODETECTINDENT_API void beNotified(SCNotification *notifyCode)
break;
}

case NPPN_FILECLOSED:
case NPPN_FILEBEFORECLOSE:
{
TCHAR path[MAX_PATH + 1] {};
myPlugin->message()->sendNppMessage<>(NPPM_GETFULLCURRENTPATH, MAX_PATH, reinterpret_cast<LPARAM>(path));
indentCache.erase(path);
break;
}

case NPPN_FILEBEFORESAVE:
{
const uptr_t bufferId = notifyCode->nmhdr.idFrom;
TCHAR oldPath[MAX_PATH + 1] {};
myPlugin->message()->sendNppMessage<>(NPPM_GETFULLCURRENTPATH, MAX_PATH, reinterpret_cast<LPARAM>(oldPath));

myPlugin->fileRenameMap[bufferId] = oldPath;
break;
}

case NPPN_FILESAVED:
{
const uptr_t bufferId = notifyCode->nmhdr.idFrom;
const std::wstring oldPath = myPlugin->fileRenameMap[bufferId];
myPlugin->fileRenameMap.erase(bufferId);

TCHAR newPath[MAX_PATH + 1] {};
myPlugin->message()->sendNppMessage<>(NPPM_GETFULLCURRENTPATH, MAX_PATH, reinterpret_cast<LPARAM>(newPath));
indentCache[newPath] = indentCache[oldPath];
indentCache.erase(oldPath);
break;
}

case NPPN_BUFFERACTIVATED:
{
if (Settings::instance()->getDisablePlugin())
Expand Down
2 changes: 1 addition & 1 deletion src/nppAutoDetectIndent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "settings.h"

#define PLUGIN_VERSION "1.5"
#define PLUGIN_VERSION "1.6"

namespace
{
Expand Down
1 change: 1 addition & 0 deletions src/nppAutoDetectIndent.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class MyPlugin

const std::array<FuncItem, 4> m_funcItems {};
nppAutoDetectIndent::IndentCache indentCache;
std::unordered_map<uptr_t, std::wstring> fileRenameMap; // <buffer id, old file path>
nppAutoDetectIndent::NppSettings nppOriginalSettings;

static constexpr TCHAR *PLUGIN_NAME = TEXT("Auto Detect Indention");
Expand Down

0 comments on commit 3d0d054

Please sign in to comment.