Skip to content

Commit 5546f98

Browse files
committed
add non-ASCII ANSI support; fix GetCurLine bug
FIX: As mentioned in this forum post (https://community.notepad-plus-plus.org/post/102725), this plugin pack was previously assuming that Notepad++ internally represented every document as UTF-8, regardless of the encoding of that document on the hard drive. This assumption appears to have been correct for every document encoding EXCEPT ANSI, which meant that non-ASCII text in ANSI documents would previously be garbled by this plugin. This issue has now been fixed. FIX: I *believe* that issue #16 has now been resolved, by adding a new parameter to GetNullStrippedStringFromMessageThatReturnsLength. ADD: Add a new popup notification when changing the lexer language for "new 1"-type buffers whose names begin with "lexer test CSharpPluginPack". This notification mostly exists to verify that the fixes for both of the above bugs actually work.
1 parent 4e7f123 commit 5546f98

File tree

4 files changed

+126
-77
lines changed

4 files changed

+126
-77
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3434
7. When building plugin, automatically sync `plugins/yourPluginName/testfiles` folder in your Notepad++ installation with the `testfiles` folder in this repo. Fix [issue #12](https://github.com/molsonkiko/NppCSharpPluginPack/issues/12).
3535
8. Toggle highlighting of `close HTML/XML tag` toolbar icon based on whether the setting is true.
3636
9. Toolbar icon hover text is now translated to other languages. Fix [issue #14](https://github.com/molsonkiko/NppCSharpPluginPack/issues/14).
37+
10. Added support for ANSI-encoded documents containing non-ASCII text. Previously, if a document was ANSI encoded, and the plugin asked for some text from the document, Notepad++ would send ANSI-encoded text and the plugin would attempt to decode it as UTF-8.
3738

3839
### Fixed
3940

NppCSharpPluginPack/Main.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,15 @@ public static void OnNotification(ScNotification notification)
203203
modsSinceBufferOpened = 0;
204204
return;
205205
// when the lexer language changed, re-check whether this is a document where we close HTML tags.
206+
// also display some text from the document and info about the current lexer if the name of the current file starts with "lexer test CSharpPluginPack".
206207
case (uint)NppMsg.NPPN_LANGCHANGED:
208+
if (Npp.notepad.GetCurrentFilePath().StartsWith("lexer test CSharpPluginPack"))
209+
{
210+
MessageBox.Show($"The current line's text is {Npp.editor.GetCurLine().TrimEnd(new char[] {'\r', '\n'})}.\r\n" +
211+
(Npp.editor.GetNamedStyles() < 2 ? "There are fewer than two named styles for this lexer.\r\n" : $"The first two named styles for this lexer are {Npp.editor.NameOfStyle(0)} and {Npp.editor.NameOfStyle(1)}.\r\n") +
212+
"This notification appeared because the lexer language just changed and the name of the current file starts with \"lexer test CSharpPluginPack\"",
213+
"CSharpPluginPack notification when lexer language is changed");
214+
}
207215
DoesCurrentLexerSupportCloseHtmlTag();
208216
break;
209217
// when closing a file

0 commit comments

Comments
 (0)