Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Commit 232ad60

Browse files
committed
Fix issue in command-line parsing on Windows with paths of the form c:/...:line:column
See rescript-lang/rescript-vscode#25
1 parent 0d74069 commit 232ad60

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

Changes.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Support syntax highlight in hover fenced blocks.
77
- Fix printing of variant arguments.
88
- Use outcome printer from the syntax to print type declarations.
9+
- Fix issue in command-line parsing on Windows with paths of the form `c:/...:line:column`.
910

1011
## Release 1.0.0 of rescript-vscode
1112
This [commit](https://github.com/rescript-lang/rescript-editor-support/commit/d45f45793a307a3bb87dcac0542fd412669f1b6e) is vendored in [rescript-vscode 1.0.0](https://github.com/rescript-lang/rescript-vscode/releases/tag/1.0.0).

src/rescript-editor-support/EditorSupportCommands.re

+17-12
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,19 @@ let dumpLocations = (state, ~package, ~file, ~extra, ~selectPos, uri) => {
104104
Json.stringify(locationsInfo);
105105
};
106106

107+
// Split (line,char) from filepath:line:char
108+
let splitLineChar = pathWithPos => {
109+
let mkPos = (line, char) =>
110+
Some((line |> int_of_string, char |> int_of_string));
111+
switch (pathWithPos |> String.split_on_char(':')) {
112+
| [filePath, line, char] => (filePath, mkPos(line, char))
113+
| [drive, rest, line, char] =>
114+
// c:\... on Windows
115+
(drive ++ ":" ++ rest, mkPos(line, char))
116+
| _ => (pathWithPos, None)
117+
};
118+
};
119+
107120
let dump = files => {
108121
Shared.cacheTypeToString := true;
109122
let rootPath = Unix.getcwd();
@@ -118,15 +131,8 @@ let dump = files => {
118131
},
119132
};
120133
files
121-
|> List.iter(filePath => {
122-
let (filePath, selectPos) =
123-
switch (filePath |> String.split_on_char(':')) {
124-
| [filePath, line, char] => (
125-
filePath,
126-
Some((line |> int_of_string, char |> int_of_string)),
127-
)
128-
| _ => (filePath, None)
129-
};
134+
|> List.iter(pathWithPos => {
135+
let (filePath, selectPos) = pathWithPos |> splitLineChar;
130136
let filePath = maybeConcat(Unix.getcwd(), filePath);
131137
let uri = Utils.toUri(filePath);
132138
let result =
@@ -241,9 +247,8 @@ let complete = (~pathWithPos, ~currentFile) => {
241247
autoRebuild: false,
242248
},
243249
};
244-
switch (pathWithPos |> String.split_on_char(':')) {
245-
| [filePath, line, char] =>
246-
let pos = (line |> int_of_string, char |> int_of_string);
250+
switch (pathWithPos |> splitLineChar) {
251+
| (filePath, Some(pos)) =>
247252
let filePath = maybeConcat(Unix.getcwd(), filePath);
248253
let uri = Utils.toUri(filePath);
249254
let result =

0 commit comments

Comments
 (0)