Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows fixes #71

Merged
merged 27 commits into from
Jan 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
188abb0
Add windows fixes for files
mewhhaha Jan 25, 2021
12fd2b7
Remove dependencies not in original repo
mewhhaha Jan 25, 2021
87512b8
Change const to let again
mewhhaha Jan 25, 2021
54bf369
Remove amusing letants
mewhhaha Jan 25, 2021
fa5934f
Remove space
mewhhaha Jan 25, 2021
37848cb
Remove the two first spaces since it is trimmed
mewhhaha Jan 25, 2021
744d5ff
Refactor separatefileandlocation function
mewhhaha Jan 25, 2021
ed6d903
Fix spacing
mewhhaha Jan 25, 2021
f484263
Add one space
mewhhaha Jan 25, 2021
1c4cb22
Merge pull request #1 from mewhhaha/master
Jan 25, 2021
8b64c80
Move findlocationseparator into other function
mewhhaha Jan 25, 2021
c8ab02a
Merge pull request #2 from mewhhaha/master
Jan 25, 2021
856de60
Reformatted some code
mewhhaha Jan 25, 2021
e984823
Merge pull request #3 from mewhhaha/master
Jan 26, 2021
e724c5e
Revert package.json
Jan 26, 2021
c077b63
Update from comments
mewhhaha Jan 26, 2021
c74302a
Revert clien package-lock.json
Jan 26, 2021
94699d9
Merge pull request #4 from mewhhaha/master
Jan 26, 2021
33b3e30
Use vscode uri utils for file scheme
mewhhaha Jan 27, 2021
3fee884
Add semicolons
mewhhaha Jan 27, 2021
7ecb7ad
Add two semicolons
mewhhaha Jan 27, 2021
88268bb
Merge pull request #5 from mewhhaha/master
Jan 27, 2021
afece3f
Remove trim call as to follow repos best practices
Jan 27, 2021
763ac4f
Merge branch 'master' of github.com:johnny88/rescript-vscode
Jan 27, 2021
0a873e1
Move to lockfile package 2
Jan 27, 2021
c73947c
Include spaces in colon separator search
Jan 27, 2021
76a9da9
We need to remove the spaces for URI.file to work
Jan 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
},
"dependencies": {
"vscode-languageserver": "^6.1.1",
"vscode-languageserver-textdocument": "^1.0.1"
"vscode-languageserver-textdocument": "^1.0.1",
"vscode-uri": "^3.0.2"
},
"scripts": {}
}
41 changes: 33 additions & 8 deletions server/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as path from "path";
import * as t from "vscode-languageserver-types";
import fs from "fs";
import * as os from "os";
import { URI } from 'vscode-uri';

let tempFilePrefix = "rescript_format_file_" + process.pid + "_";
let tempFileId = 0;
Expand Down Expand Up @@ -105,10 +106,15 @@ export let runBsbWatcherUsingValidBsbPath = (
bsbPath: p.DocumentUri,
projectRootPath: p.DocumentUri
) => {
let process = childProcess.execFile(bsbPath, ["-w"], {
cwd: projectRootPath,
});
return process;
if (process.platform === "win32") {
return childProcess.exec(`${bsbPath}.cmd -w`, {
cwd: projectRootPath,
});
} else {
return childProcess.execFile(bsbPath, ["-w"], {
cwd: projectRootPath,
})
}
// try {
// let result = childProcess.execFileSync(bsbPath, [], { stdio: 'pipe', cwd: projectRootPath })
// return {
Expand Down Expand Up @@ -154,6 +160,25 @@ export let parseDiagnosticLocation = (location: string): Range => {
}
};

let findLocationSeparator = (fileAndLocation: string) => {
// Exclude the two first letters in windows paths to avoid the first colon in eg "c:\\.."
if (process.platform === "win32") {
return fileAndLocation.indexOf(":", 2);
} else {
return fileAndLocation.indexOf(":");
}
};

let separateFileAndLocation = (fileAndLocation: string): [string, string] => {
let locationSeparator = findLocationSeparator(fileAndLocation);
let file = fileAndLocation.slice(0, locationSeparator);
let location = fileAndLocation.slice(locationSeparator + 1);

return [URI.file(file).toString(), location];
};



type filesDiagnostics = {
[key: string]: p.Diagnostic[];
};
Expand Down Expand Up @@ -273,10 +298,10 @@ export let parseCompilerLogOutput = (

let result: filesDiagnostics = {};
parsedDiagnostics.forEach((parsedDiagnostic) => {
let [fileAndLocation, ...diagnosticMessage] = parsedDiagnostic.content;
let locationSeparator = fileAndLocation.indexOf(":");
let file = fileAndLocation.substring(2, locationSeparator);
let location = fileAndLocation.substring(locationSeparator + 1);
let [fileAndLocationLine, ...diagnosticMessage] = parsedDiagnostic.content;

let [file, location] = separateFileAndLocation(fileAndLocationLine.slice(2));

if (result[file] == null) {
result[file] = [];
}
Expand Down