From 8f7b69357b0396bd869774671489d421e8cd113f Mon Sep 17 00:00:00 2001 From: Philipp A Date: Fri, 18 Aug 2023 12:53:33 +0200 Subject: [PATCH] Fix LSP crash --- .vscode/launch.json | 11 +++- Cargo.lock | 11 ++-- crates/taplo-common/Cargo.toml | 2 +- crates/taplo-wasm/Cargo.lock | 98 ++++++++++++++++++++-------------- crates/taplo-wasm/Cargo.toml | 2 +- crates/taplo/Cargo.toml | 2 +- editors/vscode/src/server.ts | 4 ++ 7 files changed, 80 insertions(+), 50 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 14cb0ef9b..695cd5af7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -236,6 +236,15 @@ }, "args": [], "cwd": "${workspaceFolder}" - } + }, + { + "name": "Launch Extension", + "type": "extensionHost", + "request": "launch", + "runtimeExecutable": "${execPath}", + "args": [ + "--extensionDevelopmentPath=${workspaceRoot}/editors/vscode", + ], + }, ] } \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 35e9772dc..266eb3d9a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,15 +25,14 @@ checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ "getrandom 0.2.8", "once_cell", - "serde", "version_check", ] [[package]] name = "ahash" -version = "0.8.0" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57e6e951cfbb2db8de1828d49073a113a29fd7117b1596caa781a258c7e38d72" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", "getrandom 0.2.8", @@ -1078,7 +1077,7 @@ version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a071f4f7efc9a9118dfb627a0a94ef247986e1ab8606a4c806ae2b3aa3b6978" dependencies = [ - "ahash 0.8.0", + "ahash 0.8.3", "anyhow", "base64 0.21.2", "bytecount", @@ -2206,7 +2205,7 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" name = "taplo" version = "0.12.1" dependencies = [ - "ahash 0.7.6", + "ahash 0.8.3", "arc-swap", "assert-json-diff", "criterion", @@ -2264,7 +2263,7 @@ dependencies = [ name = "taplo-common" version = "0.4.1" dependencies = [ - "ahash 0.7.6", + "ahash 0.8.3", "anyhow", "arc-swap", "async-recursion", diff --git a/crates/taplo-common/Cargo.toml b/crates/taplo-common/Cargo.toml index 2fd0af0d4..525b35c02 100644 --- a/crates/taplo-common/Cargo.toml +++ b/crates/taplo-common/Cargo.toml @@ -8,7 +8,7 @@ license = "MIT" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -ahash = { version = "0.7.6", features = ["serde"] } +ahash = { version = "0.8.3", features = ["serde"] } anyhow = { version = "1.0.53", features = ["backtrace"] } arc-swap = "1.5.0" async-recursion = "1.0.0" diff --git a/crates/taplo-wasm/Cargo.lock b/crates/taplo-wasm/Cargo.lock index f95cf1dcf..37eac1fda 100644 --- a/crates/taplo-wasm/Cargo.lock +++ b/crates/taplo-wasm/Cargo.lock @@ -23,7 +23,19 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ - "getrandom 0.2.7", + "getrandom 0.2.10", + "once_cell", + "version_check", +] + +[[package]] +name = "ahash" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" +dependencies = [ + "cfg-if", + "getrandom 0.2.10", "once_cell", "serde", "version_check", @@ -143,6 +155,12 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "base64" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "604178f6c5c21f02dc555784810edfb88d34ac2c73b2eae109655649ee73ce3d" + [[package]] name = "beef" version = "0.5.2" @@ -460,9 +478,9 @@ dependencies = [ [[package]] name = "fancy-regex" -version = "0.8.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95b4efe5be9104a4a18a9916e86654319895138be727b229820c39257c30dda" +checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" dependencies = [ "bit-set", "regex", @@ -499,9 +517,9 @@ dependencies = [ [[package]] name = "fraction" -version = "0.10.0" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bb65943183b6b3cbf00f64c181e8178217e30194381b150e4f87ec59864c803" +checksum = "3027ae1df8d41b4bed2241c8fdad4acc1e7af60c8e17743534b545e77182d678" dependencies = [ "lazy_static", "num", @@ -619,9 +637,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.7" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "js-sys", @@ -686,7 +704,7 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" dependencies = [ - "ahash", + "ahash 0.7.6", ] [[package]] @@ -821,9 +839,9 @@ checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" [[package]] name = "iso8601" -version = "0.4.2" +version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5b94fbeb759754d87e1daea745bc8efd3037cd16980331fe1d1524c9a79ce96" +checksum = "924e5d73ea28f59011fec52a0d12185d496a9b075d360657aed2a5707f701153" dependencies = [ "nom", ] @@ -869,21 +887,22 @@ dependencies = [ [[package]] name = "jsonschema" -version = "0.16.0" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebd40599e7f1230ce296f73b88c022b98ed66689f97eaa54bbeadc337a2ffa6" +checksum = "2a071f4f7efc9a9118dfb627a0a94ef247986e1ab8606a4c806ae2b3aa3b6978" dependencies = [ - "ahash", + "ahash 0.8.3", "anyhow", - "base64", + "base64 0.21.2", "bytecount", "fancy-regex", "fraction", + "getrandom 0.2.10", "iso8601", "itoa 1.0.3", - "lazy_static", "memchr", "num-cmp", + "once_cell", "parking_lot", "percent-encoding", "regex", @@ -959,12 +978,12 @@ dependencies = [ [[package]] name = "lsp-async-stub" -version = "0.6.0" +version = "0.6.1" dependencies = [ "anyhow", "async-trait", "futures", - "getrandom 0.2.7", + "getrandom 0.2.10", "lsp-types", "rowan", "serde", @@ -1061,9 +1080,9 @@ dependencies = [ [[package]] name = "num" -version = "0.2.1" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8536030f9fea7127f841b45bb6243b27255787fb4eb83958aa1ef9d2fdc0c36" +checksum = "b05180d69e3da0e530ba2a1dae5110317e49e3b7f3d41be227dc5f92e49ee7af" dependencies = [ "num-bigint", "num-complex", @@ -1075,9 +1094,9 @@ dependencies = [ [[package]] name = "num-bigint" -version = "0.2.6" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" dependencies = [ "autocfg", "num-integer", @@ -1092,11 +1111,10 @@ checksum = "63335b2e2c34fae2fb0aa2cecfd9f0832a1e24b3b32ecec612c3426d46dc8aaa" [[package]] name = "num-complex" -version = "0.2.4" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6b19411a9719e753aff12e5187b74d60d3dc449ec3f4dc21e3989c3f554bc95" +checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214" dependencies = [ - "autocfg", "num-traits", ] @@ -1123,9 +1141,9 @@ dependencies = [ [[package]] name = "num-rational" -version = "0.2.4" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c000134b5dbf44adc5cb772486d335293351644b801551abe8f75c84cfa4aef" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" dependencies = [ "autocfg", "num-bigint", @@ -1172,9 +1190,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.13.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "074864da206b4973b84eb91683020dbefd6a8c3f0f38e054d93954e891935e4e" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "os_str_bytes" @@ -1372,7 +1390,7 @@ version = "0.11.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b75aa69a3f06bbcc66ede33af2af253c6f7a86b1ca0033f60c580a27074fbf92" dependencies = [ - "base64", + "base64 0.13.0", "bytes", "encoding_rs", "futures-core", @@ -1439,7 +1457,7 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" dependencies = [ - "base64", + "base64 0.13.0", "blake2b_simd", "constant_time_eq", "crossbeam-utils", @@ -1475,7 +1493,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55" dependencies = [ - "base64", + "base64 0.13.0", ] [[package]] @@ -1717,9 +1735,9 @@ checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" [[package]] name = "taplo" -version = "0.12.0" +version = "0.12.1" dependencies = [ - "ahash", + "ahash 0.8.3", "arc-swap", "either", "globset", @@ -1737,7 +1755,7 @@ dependencies = [ [[package]] name = "taplo-cli" -version = "0.8.0" +version = "0.8.1" dependencies = [ "ansi_term", "anyhow", @@ -1768,9 +1786,9 @@ dependencies = [ [[package]] name = "taplo-common" -version = "0.4.0" +version = "0.4.1" dependencies = [ - "ahash", + "ahash 0.8.3", "anyhow", "arc-swap", "async-recursion", @@ -1806,7 +1824,7 @@ dependencies = [ [[package]] name = "taplo-lsp" -version = "0.6.0" +version = "0.6.1" dependencies = [ "anyhow", "arc-swap", @@ -1841,7 +1859,7 @@ dependencies = [ "clap 3.2.19", "console_error_panic_hook", "futures", - "getrandom 0.2.7", + "getrandom 0.2.10", "indexmap", "js-sys", "lsp-async-stub", @@ -2169,9 +2187,9 @@ dependencies = [ [[package]] name = "uuid" -version = "0.8.2" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" [[package]] name = "valuable" diff --git a/crates/taplo-wasm/Cargo.toml b/crates/taplo-wasm/Cargo.toml index 471bb6a5d..9a21cb231 100644 --- a/crates/taplo-wasm/Cargo.toml +++ b/crates/taplo-wasm/Cargo.toml @@ -15,7 +15,7 @@ async-trait = "0.1.56" clap = { version = "3.1.18", features = ["derive"] } console_error_panic_hook = "0.1.7" futures = "0.3.21" -getrandom = { version = "0.2.7", features = ["js"] } +getrandom = { version = "0.2.8", features = ["js"] } indexmap = "~1.6" js-sys = "0.3.57" lsp-async-stub = { path = "../lsp-async-stub" } diff --git a/crates/taplo/Cargo.toml b/crates/taplo/Cargo.toml index 966ba1db3..1beb6ccc8 100644 --- a/crates/taplo/Cargo.toml +++ b/crates/taplo/Cargo.toml @@ -16,7 +16,7 @@ default = ["serde"] schema = ["schemars"] [dependencies] -ahash = "0.7.6" +ahash = "0.8.3" arc-swap = "1.5.0" either = "1.6.1" globset = { version = "0.4.8" } diff --git a/editors/vscode/src/server.ts b/editors/vscode/src/server.ts index 64fd39c97..8f8cbf74a 100644 --- a/editors/vscode/src/server.ts +++ b/editors/vscode/src/server.ts @@ -6,6 +6,10 @@ import { RpcMessage, TaploLsp } from "@taplo/lsp"; import fetch, { Headers, Request, Response } from "node-fetch"; import glob from "fast-glob"; +import { webcrypto } from "node:crypto"; +// https://docs.rs/getrandom/latest/getrandom/#nodejs-es-module-support +globalThis.crypto = webcrypto; + let taplo: TaploLsp; process.on("message", async (d: RpcMessage) => {