Ekopalypse / NppLspClient

LSP client for Notepad++
MIT License
41 stars 3 forks source link

Log file is padded with `NULL`s when reloaded in Notepad++ #12

Closed rdipardo closed 9 months ago

rdipardo commented 9 months ago

When enable_logging is true and NppLspClient_<PID>.log is updated while open in Notepad++, ~36KB of NULL bytes are written before the first log entry, e.g.,

npplspclient-null-log

To reproduce

[general]
diag_indicator_id = 12  
error_color = 0x756ce0  
warning_color = 0x64e0ff  
incoming_msg_color = 0x7bc399  
outgoing_msg_color = 0xffac59  
selected_text_color = 0x745227  
highlight_indicator_id = 13  
highlight_indicator_color = 0x64e0ff  
enable_logging = true  # IMPORTANT!
clear_reference_view_always = false  

[lspservers.rust]
mode = "io"
executable = 'C:\\FULL\\PATH\\TO\\rust-analyzer.exe'
auto_start_server = false

Encountered in the following environment:

Notepad++ v8.6.3   (64-bit)
Build time : Feb 16 2024 - 20:08:05
Path : C:\Users\Rob\dev\npp.8.6.3-rc2\notepad++.exe
Command Line :
Admin mode : OFF
Local Conf mode : ON
Cloud Config : OFF
OS Name : Windows 10 Pro (64-bit)
OS Version : 22H2
OS Build : 19045.4046
Current ANSI codepage : 1252
Plugins :
    NppLspClient (0.0.24)

rustc 1.76.0 (07dca489a 2024-02-04)
rust-analyzer 1.76.0 (07dca489 2024-02-04)
Ekopalypse commented 9 months ago

Thank you very much. Thanks to your description, I was able to reproduce the problem on my site. It should be fixed with the next version.

rdipardo commented 9 months ago

Just to clarify the description a bit, the one essential precondition seems to be a zero-length log file. Write anything and save it first, the NULLs never appear, even in current builds. Sometimes the LSP server will go ahead and flush a message like "logging initialized" as soon as it starts. Then, too, there's no issue.

In other words, it looks like a typical race condition. Sometimes the log gets flushed before Notepad++ can open it, and sometimes not.

Ekopalypse commented 9 months ago

The problem in this version is that every time someone saves the config file, I recreate the log file, which confuses the logging module, which writes to the next place it knows, with the result that the NULL bytes, the overwritten part of the previous file, have now been inserted at the beginning. tststs ... stupid of me. Will be fixed with the next version.

Ekopalypse commented 9 months ago

@rdipardo - should be solved with v.0.0.25-alpha. The resizing of dialogs has also been implemented.

rdipardo commented 9 months ago

should be solved with v.0.0.25-alpha

Confirmed!