Skip to content

Commit 40d1291

Browse files
committed
fix(vscode): fix wrong squigglies on first load on Windows
dlltool, used when building with GCC-MinGW, has a bug which causes the first call to napi_create_double to create 1.20305e-307 instead of the intended number. Work around this dll bug by making a dummy call to napi_create_double on init to absorb the corruption.
1 parent 288fe6c commit 40d1291

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

plugin/vscode/quick-lint-js-vscode-node.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,19 @@ std::unique_ptr<addon_state> addon_state::create(::Napi::Env env) {
10511051
return state;
10521052
}
10531053

1054+
// Work around a bug in MinGW's dlltool when calling certain
1055+
// N-API functions.
1056+
// https://lists.gnu.org/archive/html/bug-binutils/2022-05/msg00099.html
1057+
void work_around_dlltool_bug(::napi_env env) {
1058+
// Call all napi_ functions with any double parameters.
1059+
::napi_value value;
1060+
::napi_create_double(env, 0.0, &value);
1061+
::napi_create_date(env, 0.0, &value);
1062+
}
1063+
10541064
::Napi::Object initialize_addon(::Napi::Env env, ::Napi::Object exports) {
1065+
work_around_dlltool_bug(env);
1066+
10551067
std::unique_ptr<addon_state> state = addon_state::create(env);
10561068
env.SetInstanceData<addon_state>(state.get());
10571069
state.release();

0 commit comments

Comments
 (0)