oleg-shilo / cs-script.npp

CS-Script (C# Intellisense) plugin for Notepad++ (x86/x64)
MIT License
246 stars 52 forks source link

Close hang #59

Closed KnIfER closed 7 months ago

KnIfER commented 3 years ago

close an arbitary big file(>10mb), npp hangs for a while, lose response.

close an inactive big file won't cause. test in npp8.0x64

oleg-shilo commented 3 years ago

I am not sure the file is a C# source (you did not mention). It's rather unusual to have such large C# files.

But just in case if indeed you work with large cs file you can disable formatting on save: image

KnIfER commented 3 years ago

No, the file is not a C# source. and formatting on save is already disabled

I unchecked all settings and the problem is still there.

oleg-shilo commented 3 years ago

Ok... then it seems this extension has nothing to do with the problem. Am I missing something?

KnIfER commented 3 years ago

NO.

Remove the folder CSScriptNpp ==> problem is gone.

Put it back ==> Closing file hangs NPP

Bigger file ==> Freeze for more time.

oleg-shilo commented 3 years ago

What type of the file you are opening. When I open mp4 (200+Mb) and close Npp is does not cause the problem.

The only activity that CS-Script does on exit is asking Scintilla (NPP rendering engine) if there are any markers (breakpoints) are associated with the current document: https://github.com/oleg-shilo/cs-script.npp/blob/ba29b04176d946af2eed02ba7f67fab572092d8c/src/CSScriptIntellisense/Interop/NppExtensions.cs#L197

This is a legal but expensive call. Scintilla does not have the API for getting the markers from the whole doc so one needs to go through the all lines and check them one by one.

In case of binary file it's only one line. All good. But if the file you open is a text file then indeed it will take a while to go through the all lines.

So was it a text file in your case?

oleg-shilo commented 3 years ago

Nevertheless I have disabled saving breakpoints for the file types that are not script files. It will help. But of course it will still be a problem if a huge cs file is opened.

The change will be available in the next release.

I will try to publish the fix rather very soon so you can update the plugin manually.

KnIfER commented 3 years ago

Yes I was viewing a big json file .

for loops……

 // while (-1 != (line = document.MarkerNext(++line, mask)))

Why not MarkerNext, doc says it's more efficient?

oleg-shilo commented 3 years ago

It was unreliable. :( API design wise it was exactly the method that was needed but it was missing some markers for no obvious reason and breakpoints were not saved fully.

So resorted to line by line inefficient iterations.