Skip to content

Commit 314909e

Browse files
committed
Better location parsing
1 parent d21e19b commit 314909e

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

server/src/testserver.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,24 @@ let formatUsingValidBscPath = (code: string, bscPath: p.DocumentUri, isInterface
7777
let parseBsbOutputLocation = (location: string): Range => {
7878
// example bsb output location:
7979
// 3:9
80+
// 3:5-8
8081
// 3:9-6:1
82+
8183
// language-server position is 0-based. Ours is 1-based. Don't forget to convert
82-
let isMultiline = location.indexOf('-') >= 0
83-
if (isMultiline) {
84+
// also, our end character is inclusive. Language-server's is exclusive
85+
let isRange = location.indexOf('-') >= 0
86+
if (isRange) {
8487
let [from, to] = location.split('-')
8588
let [fromLine, fromChar] = from.split(':')
86-
let [toLine, toChar] = to.split(':')
89+
let isSingleLine = to.indexOf(':') >= 0
90+
let [toLine, toChar] = isSingleLine ? to.split(':') : [fromLine, to]
8791
return {
88-
start: { line: parseInt(fromLine) - 1, character: parseInt(fromChar) },
92+
start: { line: parseInt(fromLine) - 1, character: parseInt(fromChar) - 1 },
8993
end: { line: parseInt(toLine) - 1, character: parseInt(toChar) },
9094
}
9195
} else {
9296
let [line, char] = location.split(':')
93-
let start = { line: parseInt(line) - 1, character: parseInt(char) - 1 }
97+
let start = { line: parseInt(line) - 1, character: parseInt(char) }
9498
return {
9599
start: start,
96100
end: start,
@@ -107,6 +111,18 @@ Cleaning... 87 files.
107111
[2/5] [34mBuilding[39m [2msrc/TestFramework.reast[22m
108112
FAILED: src/test.cmj src/test.cmi
109113
114+
Warning number 8
115+
/Users/chenglou/github/reason-react/src/test.res 3:5-8
116+
117+
1 │ let a = j`😀`
118+
2 │ let b = `😀`
119+
3 │ let None = None
120+
4 │ let bla: int = "
121+
5 │ hi
122+
123+
You forgot to handle a possible case here, for example:
124+
Some _
125+
110126
We've found a bug for you!
111127
/Users/chenglou/github/reason-react/src/test.res 3:9
112128
@@ -130,6 +146,8 @@ FAILED: src/test.cmj src/test.cmi
130146
lines.forEach(line => {
131147
if (line.startsWith(' We\'ve found a bug for you!')) {
132148
res.push([])
149+
} else if (line.startsWith(' Warning number ')) {
150+
res.push([])
133151
} else if (/^ [0-9]+ /.test(line)) {
134152
// code display. Swallow
135153
} else if (line.startsWith(' ')) {

0 commit comments

Comments
 (0)