From f0e48675b809af01826683866806f1ab9ed617f0 Mon Sep 17 00:00:00 2001 From: sockmaster27 <61235930+sockmaster27@users.noreply.github.com> Date: Sat, 27 Jan 2024 20:51:19 +0100 Subject: [PATCH] Use `vscode-uri` --- server/package-lock.json | 11 +++++++++++ server/package.json | 1 + server/src/engine/flix.ts | 7 ++----- server/src/handlers/handlers.ts | 25 ++++++++++++++++++------- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/server/package-lock.json b/server/package-lock.json index c8d74711..d65cb4e3 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -13,6 +13,7 @@ "portfinder": "^1.0.32", "vscode-languageserver": "^8.0.2", "vscode-languageserver-textdocument": "^1.0.8", + "vscode-uri": "^3.0.8", "ws": "^8.11.0" }, "devDependencies": { @@ -124,6 +125,11 @@ "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz", "integrity": "sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==" }, + "node_modules/vscode-uri": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.8.tgz", + "integrity": "sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==" + }, "node_modules/ws": { "version": "8.11.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", @@ -233,6 +239,11 @@ "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2.tgz", "integrity": "sha512-zHhCWatviizPIq9B7Vh9uvrH6x3sK8itC84HkamnBWoDFJtzBf7SWlpLCZUit72b3os45h6RWQNC9xHRDF8dRA==" }, + "vscode-uri": { + "version": "3.0.8", + "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.8.tgz", + "integrity": "sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==" + }, "ws": { "version": "8.11.0", "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz", diff --git a/server/package.json b/server/package.json index b4b45e9c..e867f366 100644 --- a/server/package.json +++ b/server/package.json @@ -16,6 +16,7 @@ "portfinder": "^1.0.32", "vscode-languageserver": "^8.0.2", "vscode-languageserver-textdocument": "^1.0.8", + "vscode-uri": "^3.0.8", "ws": "^8.11.0" }, "devDependencies": { diff --git a/server/src/engine/flix.ts b/server/src/engine/flix.ts index e0ff378c..63f1ce11 100644 --- a/server/src/engine/flix.ts +++ b/server/src/engine/flix.ts @@ -20,6 +20,7 @@ import javaVersion from '../util/javaVersion' import { ChildProcess, spawn } from 'child_process' import { getPortPromise } from 'portfinder' import * as _ from 'lodash' +import { URI } from 'vscode-uri' import * as jobs from './jobs' import * as queue from './queue' @@ -77,11 +78,7 @@ export function getExtensionVersion() { export function getProjectRootUri() { const path = _.first(startEngineInput.workspaceFolders)! - - // This is the format that that VSCode forwards the URI in - const escapedPath = path.replace(':', '%3A') - - return new URL(`file:///${escapedPath}`) + return URI.file(path) } export function updateUserConfiguration(userConfiguration: UserConfiguration) { diff --git a/server/src/handlers/handlers.ts b/server/src/handlers/handlers.ts index 830f3af2..4ab92ab5 100644 --- a/server/src/handlers/handlers.ts +++ b/server/src/handlers/handlers.ts @@ -35,6 +35,7 @@ import { USER_MESSAGE } from '../util/userMessages' import { StatusCode } from '../util/statusCodes' import _ = require('lodash/fp') +import { URI } from 'vscode-uri' interface UriInput { uri: string @@ -167,7 +168,7 @@ export function handleChangeContent(params: TextDocumentChangeEvent new RegExp(regExpString)) - return regExps.some(regExp => regExp.test(uri)) + + return pathRegExps.some(pathRegExp => pathRegExp.test(uri.path)) } /**