diff --git a/src/dllmain.cpp b/src/dllmain.cpp index d65ba2f..865a7b4 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -77,9 +77,9 @@ extern "C" NPPAUTODETECTINDENT_API void beNotified(SCNotification *notifyCode) case NPPN_FILECLOSED: { - const uptr_t id = notifyCode->nmhdr.idFrom; - - indentCache.erase(id); + TCHAR path[MAX_PATH + 1] {}; + myPlugin->message()->sendNppMessage<>(NPPM_GETFULLCURRENTPATH, MAX_PATH, reinterpret_cast(path)); + indentCache.erase(path); break; } @@ -88,12 +88,12 @@ extern "C" NPPAUTODETECTINDENT_API void beNotified(SCNotification *notifyCode) if (Settings::instance()->getDisablePlugin()) break; - const uptr_t id = notifyCode->nmhdr.idFrom; + TCHAR path[MAX_PATH + 1] {}; + myPlugin->message()->sendNppMessage<>(NPPM_GETFULLCURRENTPATH, MAX_PATH, reinterpret_cast(path)); - const auto iter = indentCache.find(id); + const auto iter = indentCache.find(path); const nppAutoDetectIndent::IndentInfo info = (iter != indentCache.end()) ? iter->second : nppAutoDetectIndent::detectIndentInfo(); - - indentCache[id] = info; + indentCache[path] = info; applyIndentInfo(info); break; } diff --git a/src/nppAutoDetectIndent.cpp b/src/nppAutoDetectIndent.cpp index b3b859c..8390af5 100644 --- a/src/nppAutoDetectIndent.cpp +++ b/src/nppAutoDetectIndent.cpp @@ -21,7 +21,7 @@ #include "settings.h" -#define PLUGIN_VERSION "1.4" +#define PLUGIN_VERSION "1.5" namespace { @@ -141,10 +141,11 @@ namespace MenuAction } else { - const int id = plugin->message()->sendNppMessage(NPPM_GETCURRENTBUFFERID, 0, 0); + TCHAR path[MAX_PATH + 1] {}; + plugin->message()->sendNppMessage<>(NPPM_GETFULLCURRENTPATH, MAX_PATH, reinterpret_cast(path)); const nppAutoDetectIndent::IndentInfo info = nppAutoDetectIndent::detectIndentInfo(); - plugin->indentCache[id] = info; + plugin->indentCache[path] = info; applyIndentInfo(info); } } diff --git a/src/nppAutoDetectIndent.h b/src/nppAutoDetectIndent.h index 48f0a4d..f483799 100644 --- a/src/nppAutoDetectIndent.h +++ b/src/nppAutoDetectIndent.h @@ -45,7 +45,7 @@ namespace nppAutoDetectIndent NppSettings detectNppSettings(); void applyNppSettings(const NppSettings &settings); - using IndentCache = std::unordered_map; // + using IndentCache = std::unordered_map; // } class MyPlugin