diff --git a/package-lock.json b/package-lock.json index 9184c0f6d4d60cb918f95cc528656182719d94a9..1992a2d93506b81f689a45031e694a69cb864b55 100755 --- a/package-lock.json +++ b/package-lock.json @@ -1027,6 +1027,12 @@ "@types/istanbul-lib-coverage": "*", "@types/istanbul-lib-report": "*" } }, + "@types/js-levenshtein": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@types/js-levenshtein/-/js-levenshtein-1.1.0.tgz", + "integrity": "sha512-14t0v1ICYRtRVcHASzes0v/O+TIeASb8aD55cWF1PidtInhFWSXcmhzhHqGjUWf9SUq1w70cvd1cWKUULubAfQ==", + "dev": true + }, "@types/mocha": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.1.tgz", @@ -4597,6 +4603,12 @@ } } } }, + "js-levenshtein": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.6.tgz", + "integrity": "sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g==", + "dev": true + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -6089,12 +6101,6 @@ "resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz", "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==", "dev": true, "optional": true - }, - "sift-string": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/sift-string/-/sift-string-0.0.2.tgz", - "integrity": "sha1-G7ArEhslu4sHRwQr+afh2s+PuJw=", - "dev": true }, "signal-exit": { "version": "3.0.3", diff --git a/package.json b/package.json index f399df99c40cb8d1c9083f46fc85ccf23f4a8d96..bf55ce613253e1ee6350bb89244b6b5e2be37a30 100755 --- a/package.json +++ b/package.json @@ -156,6 +156,7 @@ "test": "jest" }, "devDependencies": { "@ctrl/tinycolor": "^3.1.0", + "@types/js-levenshtein": "^1.1.0", "@types/mocha": "^5.2.0", "@types/moo": "^0.5.3", "@types/node": "^13.9.3", @@ -175,6 +176,8 @@ "globrex": "^0.1.2", "import-from": "^3.0.0", "jest": "^25.5.4", { + "scopeName": "tailwindcss.injection", +{ "type": "git", "mitt": "^1.2.0", "mkdirp": "^1.0.3", @@ -185,7 +188,6 @@ "postcss-selector-parser": "^6.0.2", "resolve-from": "^5.0.0", "rimraf": "^3.0.2", "semver": "^7.3.2", - "sift-string": "0.0.2", "stack-trace": "0.0.10", "terser": "^4.6.12", "tiny-invariant": "^1.1.0", diff --git a/src/lsp/util/closest.ts b/src/lsp/util/closest.ts index ebdfacc270c2c5467d501b4ff4642aef04f6277e..3153cb8e8a48bde030c2d34d4149b2a364a9e942 100644 --- a/src/lsp/util/closest.ts +++ b/src/lsp/util/closest.ts @@ -1,5 +1,7 @@ -import sift from 'sift-string' +import levenshtein from 'js-levenshtein' export function closest(input: string, options: string[]): string | undefined { - return options.concat([]).sort((a, b) => sift(input, a) - sift(input, b))[0] + return options.sort( + (a, b) => levenshtein(input, a) - levenshtein(input, b) + )[0] }