From 4c3a67b2eafa9721c5de3f671d10e60ab2d43865 Mon Sep 17 00:00:00 2001 From: Leonard de Ruijter Date: Mon, 28 Feb 2022 01:49:13 +0100 Subject: [PATCH] Fix regression causing older versions of NotePad++ to crash (#13382) Fixes regression caused by #13364 Closes #13397 Summary of the issue: The version matching to apply the new NP++ 8.3+ behavior was incorrect, as it doesn't work for versions like 8.2.1 and 8.1.9.2. Description of how this pull request fixes the issue: Only match against the first character of the minor version. Testing strategy: Tested on version 8.1.9.2, 8.2.1, 8.3 and 8.3.1 of NP++ --- source/appModules/notepadPlusPlus.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/appModules/notepadPlusPlus.py b/source/appModules/notepadPlusPlus.py index 08e3fdb914e..62d2d8713fc 100644 --- a/source/appModules/notepadPlusPlus.py +++ b/source/appModules/notepadPlusPlus.py @@ -46,7 +46,12 @@ class NppEdit(ScintillaBase.Scintilla): def _get_TextInfo(self): if self.appModule.is64BitProcess: appVerMajor, appVerMinor, *__ = self.appModule.productVersion.split(".") - if int(appVerMajor) >= 8 and int(appVerMinor) >= 3: + # When retrieving the version, Notepad++ concatenates + # minor, patch, build in major.minor.patch.build to the form of major.minor + # https://github.com/notepad-plus-plus/npp-usermanual/blob/master/content/docs/plugin-communication.md#nppm_getnppversion + # e.g. '8.3' for '8.3', '8.21' for '8.2.1' and '8.192' for '8.1.9.2'. + # Therefore, only use the first digit of the minor version to match against version 8.3 or later. + if int(appVerMajor) >= 8 and int(appVerMinor[0]) >= 3: return ScintillaTextInfoNpp83 return super().TextInfo