Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Add patch for NaN, Inf compiler errors, quality-of-life improvement in WhatIsNpp #94

Closed
wants to merge 4 commits into from

Conversation

molsonkiko
Copy link
Contributor

@molsonkiko molsonkiko commented Aug 25, 2022

As noted in issue #93, some dependency in the project causes compiler errors if the compiler sees double.Infinity, double.NegativeInfinity, double.NaN, or anything else like 1d / 0d that can be compiled to one of those via static analysis.

The NanInf class would solve that simply by safely creating those at runtime. I added a menu command with information on these errors and how to use the class. It's a crude and inelegant solution, but it works.

I also replaced insertCurrentPath with getCurrentPath, so you can get the current absolute file path as a string. I used this to periodically check the active file in whatIsNpp so that changing the active file stops the printing of text.

I changed the argument type for NotepadPPGateway.GetFilePath from int to IntPtr to ensure that it can handle the 64-bit buffer ID's made by 64-bit Notepad++, and also added a new plugin command, Show files closed this session, to illustrate how this method can be used to register the name of a file when it's closed (since the user might close a file other than the currently open file).

I flagged IScintillaGateway.SetLexerLanguage as not working and indicated that people should use INotepadPPGateway.SetCurrentLanguage instead.
Nothing groundbreaking, but I think it's probably good to have.

WhatIsNpp previously continued writing text slowly
even if the user switched files during the writing.
This led to annoying addition of text to existing files
with no way to stop it other than closing Notepad++.

Now simply switching files will terminate this process.
MAJOR ADDITIONS
Some issue (probably associated with IlMerge and
more indirectly with [ildasm.exe](https://developercommunity.visualstudio.com/t/ildasmexe-regression-with-infinum-floating-point-v/545431)
causes compiler errors whenever you use
double.NegativeInfinity, double.PositiveInfinity,
or double.NaN.

You can use NanInf.neginf, NanInf.inf, and NanInf.nan
instead. They're just generated at runtime.

MINOR CHANGES
Change the callbackWhatIsNpp function so that it prints
text a little more quickly, and also stops printing
text if the active file changes. That way it doesn't
keep typing into existing files when you don't want it to.
Previously the GetFilePath method of NotepadPPGateway
was unusable in 64-bit Notepad++ because it accepted an
int parameter, but the buffer id (the IdFrom parameter of
the NPPN_FILEBEFORECLOSE notification) could be 64-bit.

Also added a new plugin command to Demo.cs illustrating how
tracking the NPPN_FILEBEFORECLOSE notification allows
the plugin to keep a list of all the filenames that were
closed this session.
@molsonkiko
Copy link
Contributor Author

I'm going to close this PR and reopen with just the NanInf.cs addition. This should make my changes easier to review and merge.

I will also create a PR with just the int->IntPtr change in GetFilePath.

@molsonkiko molsonkiko closed this Apr 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant