Skip to content

Commit f400090

Browse files
authored
Fix #5 (#6)
1 parent b755e6a commit f400090

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

package-lock.json

+6-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "The official VSCode plugin for ReScript.",
44
"author": "chenglou",
55
"license": "MIT",
6-
"version": "0.0.4",
6+
"version": "0.0.5",
77
"repository": {
88
"type": "git",
99
"url": "https://github.com/rescript-lang/rescript-vscode"
@@ -98,6 +98,7 @@
9898
},
9999
"dependencies": {
100100
"@types/tmp": "^0.2.0",
101-
"tmp": "^0.2.1"
101+
"tmp": "^0.2.1",
102+
"vscode-uri": "^2.1.2"
102103
}
103104
}

server/src/server.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as childProcess from 'child_process';
1111
import { DidOpenTextDocumentNotification, DidChangeTextDocumentNotification, DidCloseTextDocumentNotification } from 'vscode-languageserver-protocol';
1212
import * as tmp from 'tmp';
1313
import { Range } from 'vscode-languageserver-textdocument';
14+
import { uriToFsPath, URI } from 'vscode-uri';
1415

1516
// See https://microsoft.github.io/language-server-protocol/specification Abstract Message
1617
// version is fixed to 2.0
@@ -203,8 +204,7 @@ let startWatchingBsbOutputFile = (root: p.DocumentUri, process: NodeJS.Process)
203204
let openFiles = Object.keys(stupidFileContentCache);
204205
let bsbLogDirs: Set<p.DocumentUri> = new Set();
205206
openFiles.forEach(openFile => {
206-
// TODO: remove this hack
207-
let filePath = openFile.replace('file://', '');
207+
let filePath = uriToFsPath(URI.parse(openFile), true);
208208
let bsbLogDir = findDirOfFileNearFile(bsbLogPartialPath, filePath)
209209
if (bsbLogDir != null) {
210210
bsbLogDirs.add(bsbLogDir);
@@ -355,8 +355,7 @@ process.on('message', (a: (m.RequestMessage | m.NotificationMessage)) => {
355355
}
356356
} else if (aa.method === p.DocumentFormattingRequest.method) {
357357
let params = (aa.params as p.DocumentFormattingParams)
358-
// TODO: remove this hack
359-
let filePath = params.textDocument.uri.replace('file://', '')
358+
let filePath = uriToFsPath(URI.parse(params.textDocument.uri), true);
360359
let extension = path.extname(params.textDocument.uri);
361360
if (extension !== resExt && extension !== resiExt) {
362361
let response: m.ResponseMessage = {

0 commit comments

Comments
 (0)