pnedev / comparePlus

Compare plugin for Notepad++
GNU General Public License v3.0
1.01k stars 139 forks source link

Annotations have pink background after compare #362

Closed vinsworldcom closed 1 year ago

vinsworldcom commented 1 year ago

From a clean install of the Notepad++ 64-bit 8.5.4 latest version, whenever I do a compare, any subsequent use of annotations just shows a "pink" line. I think it may have something to do with the styles set and the markers assigned during compare?

1) Open Notepad++ and use File => New to have 2 open files 2) Plugins => ComparePlus => Compare 3) The blank files will "compare" and provide the "Files match .." prompt, just press "OK" 4) Using the NppExec Plugin, set an annotation style and make them visible:

SCI_SENDMSG SCI_ANNOTATIONSETSTYLE 0 95 SCI_SENDMSG SCI_ANNOTATIONSETVISIBLE 2

5) Using the NppExec plugin, set an annotation:

SCI_SENDMSG SCI_ANNOTATIONSETTEXT 0 "hello world"

6) It appears pink:

image

By contrast, here is steps 4 - 5 without having run a compare first:

image

Debug Info:

Notepad++ v8.5.4 (64-bit) Build time : Jun 17 2023 - 20:42:45 Path : C:\Users\mvincent\Downloads\npp\notepad++.exe Command Line : Admin mode : OFF Local Conf mode : ON Cloud Config : OFF OS Name : Windows 10 Enterprise (64-bit) OS Version : 21H2 OS Build : 19044.3208 Current ANSI codepage : 1252 Plugins : ComparePlus (1.1) mimeTools (2.9) NppConverter (4.5) NppExec (0.8.5) NppExport (0.4)

vinsworldcom commented 1 year ago

The issue seems to stem from:

"src/NppHelpers.cpp"

206: void setBlanksStyle(int view, int blankColor)
207: {
208:    if (blankStyle[view] == 0)
209:        blankStyle[view] = static_cast<int>(CallScintilla(view, SCI_ALLOCATEEXTENDEDSTYLES, 1, 0));
210: 
211:    CallScintilla(view, SCI_ANNOTATIONSETSTYLEOFFSET,   blankStyle[view], 0);

which sets the SCI_ANNOTATIONSETSTYLEOFFSET to 256 where in Notepad++, it is normally 0. After closing compares, it is never reset back to 0. Manually setting it back to 0, via NppExec for example:

SCI_SENDMSG SCI_ANNOTATIONSETSTYLEOFFSET 0

makes the Pink annotations go away.

Perhaps adding a call to SCI_ANNOTATIONSETSTYLEOFFSET setting to 0 when closing compares can be added?

Cheers.

pnedev commented 1 year ago

Hi @vinsworldcom ,

Yes, I am using in ComparePlus Scintilla annotations to mark the blank lines but I never thought that they were used in Notepad++ and that's why I didn't bother to store their config before compare and restore them after. I'll make the necessary changes.

BR

vinsworldcom commented 1 year ago

but I never thought that they were used in Notepad++

They aren't, but I have a plugin / PythonScript that uses them. I'm using styles 95-97 so I try to stay high above any used. I really think all that is needed is to "reset" SCI_ANNOTATIONSETSTYLEOFFSET back to 0 when you close compares.

Cheers.

pnedev commented 1 year ago

Hello again Vince,

Could you try the last master branch build? Here are the compiled binaries: 64-bit / 32-bit

Please close this ticket if things are working OK for you now. Thanks.

vinsworldcom commented 1 year ago

@pnedev

So it resolves the case when you compare 2 different files and then do a Plugins => ComparePlus => Clear All Compares. However, in my example, where 2 files are the same and you get the files are the same prompt, it still has the issue. I think when you compare and the files match, you'll also need to reset the SCI_ANNOTATIONSETSTYLEOFFSET back to 0

Cheers.

pnedev commented 1 year ago

Ah, OK, can you please try again with this binary: 32-bit / 64-bit ?

Thanks again.

vinsworldcom commented 1 year ago

@pnedev That appears to have done it!

Thank you for the quick turnaround!

Cheers.

vinsworldcom commented 1 year ago

@pnedev

I may have spoken too soon, the e6bcb086 commit causes some issues on exiting Notepad++. It doesn't crash, but I get an hour glass for some time and using ProcExp, I see WerFault running with Notepad++ context:

image

This does not happen with the previous commit.

Cheers.

pnedev commented 1 year ago

Hi Vince,

Thanks for letting me know. I have reverted https://github.com/pnedev/comparePlus/commit/e6bcb08677f7a76bd4b5d0181ec5a08560f2dbc2 then - it is not strictly necessary as the allocated Scintilla styles are gone when Notepad++ stops anyway (it is very unlikely that the user will just unload ComparePlus and continue working in Notepad++). Please try 32-bit or 64-bit and let me know if that works properly.

BR

vinsworldcom commented 1 year ago

@pnedev

Thank you for the quick response. I just tried the new 64-bit from 1d4a0717 and I no longer see the extended Notepad++ close or the Windows fault reporting. I think that did it!

Thank you for your continued innovation on this essential plugin!

Cheers.