-
Notifications
You must be signed in to change notification settings - Fork 57
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
Windows fixes #71
Conversation
Error diagnostics fixes for Windows
Move findlocationseparator into other function
Reformatted some code
Reverting package.json as it is a unnecessary change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot! Left some comments =D
server/src/utils.ts
Outdated
cwd: projectRootPath, | ||
}); | ||
return process; | ||
switch (os.platform()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use process.platform
. Or are we all supposed to switch to os.platform()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, missed that! Will change to process.platform. 😄
server/src/utils.ts
Outdated
}); | ||
return process; | ||
switch (os.platform()) { | ||
case "win32": return childProcess.exec(`${bsbPath}.cmd -w`, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if-else please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe all these switch statements I introduced should be if-else? Would that be better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed all of them into if elses.
client/package-lock.json
Outdated
@@ -1,264 +1,8 @@ | |||
{ | |||
"name": "rescript-language-client", | |||
"version": "0.0.1", | |||
"lockfileVersion": 2, | |||
"lockfileVersion": 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Humm I guess this should not be in this diff? Also the team's using a newer version of npm, thus the lockfile version difference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. Should restore the lock-file. 👍
server/src/utils.ts
Outdated
let location = fileAndLocation.substring(locationSeparator + 1); | ||
let [fileAndLocationLine, ...diagnosticMessage] = parsedDiagnostic.content; | ||
|
||
let fileAndLocation = fileAndLocationLine.trim() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the trim here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw that the lines came in with spacing in front of the path, like: ' C:\rescript-project-template\src\Demo.res:1:14-20\r\r'. Would have to remove the whitespace so it's possible to slice off the drive letter and colon afterwards. I think this was done with .slice(2) before. Would you rather it be done using that method? Is it always 2 spaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was substring(2)
but that's the issue we saw. It can be done in the original way.
I do feel like trim makes it clearer what's going on, and can be more robust if the compiler decides to change the number of spaces (like @mewhhaha seems to be implying from 'Is it always 2 spaces')
Let us know which you prefer and it's an easy fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, the 2 spaces is guaranteed. I've put a note here just now: https://github.com/rescript-lang/rescript-vscode/blob/20841214830a3a81140f63a8973ab5d08cfcd79f/CONTRIBUTING.md#compilerlog
Whenever it's not, it's a bug that shouldn't be covered up here, but rather fixed int the compiler. We've caught a few compiler diagnostics display bugs this way actually.
In general also, we'd like to avoid trimming: https://github.com/rescript-lang/rescript-vscode/blob/20841214830a3a81140f63a8973ab5d08cfcd79f/CONTRIBUTING.md#formatting-newline
FYI trimming has caused and hidden all sorts of bugs before. Sometime the formatting adds a newline, or two, then the editor trims, adds a new line, or whatever. Lots of little shuffling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll go ahead and fix this and change it back to the cutting out the 2 spaces using substring.
Update from comments
Btw, what about rescript-vscode/server/src/utils.ts Line 73 in 2084121
|
server/src/utils.ts
Outdated
let file = fileAndLocation.slice(0, locationSeparator) | ||
let location = fileAndLocation.slice(locationSeparator + 1) | ||
if (process.platform === "win32") { | ||
return [`file:\\\\\\${file}`, location]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what's this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Somewhat related: I had a note about file:
at
rescript-vscode/server/src/utils.ts
Line 20 in 2084121
// TODO: this doesn't handle file:/// scheme |
file:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think so too, I'll try it and see if that gives us the same result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be working on my Ubuntu and Windows 10. Do you see the current approach (Uri.file(..)) to be an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should be what @chenglou was talking about, the utility vscode has for handling files.
Use the file scheme for everything
This is a reversion
Sorry, maybe I got ahead of myself but I thought the vscode-uri util would have been more useful; I guess not right now. Merging now. Thanks so much! Could you test master afterward? Then I'll make a release. |
I tried it on my Windows 10 machine and it worked! Thanks! |
I've cleaned up the file and location parsing code to parse even more seriously in fc2e73f. Now it doesn't accidentally parse the wrong Will release tomorrow. |
It seems like a good idea to match on the consistent part of the incoming line, however this regex doesn't work for me as the incoming line looks like |
You mean |
I would've expected \r\n, but the debugger gives me \r\r. Is that just an issue with the debugger? |
Ah probably because of rescript-vscode/server/src/utils.ts Line 247 in 1cd7b81
|
Maybe splitting on /\r?\n/ would help? EDIT: I still get a \r left when splitting on /\r?\n/, which I could have expected (╯°□°)╯︵ ┻━┻ |
I'm splitting on |
It doesn't work for me. There are still lingering \r characters on some of the lines. Maybe it'd help if I posted the content of what's being read from the compiler.log:
|
That log file consists of bsb, ninja and ocaml's format module, so I'm thinking maybe there's some mix of hard-coded |
Splitting on /\r?\r?\n/ would work, but maybe that's circumventing the issue. Seems like it's \r\n that's being translated into \r\r\n at least and it only occurs between #Start and #Done. Perhaps it looked like #Start(..)\n\r\n.. at some point and then all newlines were prefixed with an \r, like (\r)\n\r(\r)\n. |
Ugh, I guess I'll have to end up using |
Done! |
I think it'd be the most maintainable way of doing it, just trim instead of slice. \r?\r?\n? just feels like someone would go in and accidentally "correct" it later on. But you could limit the trim to Windows if you want. 🎈 |
I'll try it out! |
It's working. Thank you very much! Great work! |
Np. Don't like the circumvention that hides more bug, but it'll have to do for now =) |
Yes, I understand. I think so too. But at least the first impression for Windows users will be much better now! |
Some fixes to the extension on windows including showing errors and running bsb.
Thanks to @mewhhaha for doing all the work!
Fixes #41