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

Commit 8de51da

Browse files
committed
Minor refactor to cmtLocFromVscode
1 parent 200d86b commit 8de51da

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/EditorSupportCommands.ml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ let dumpLocations state ~package ~file ~extra ~selectPos uri =
1515
in
1616
let locations =
1717
match selectPos with
18-
| Some pos -> (
19-
let pos = Utils.cmtLocFromVscode pos in
18+
| Some (line, col) -> (
19+
let pos = Utils.protocolLineColToCmtLoc ~line ~col in
2020
match References.locForPos ~extra:{extra with locations} pos with
2121
| None -> []
2222
| Some l -> [l])
@@ -130,8 +130,7 @@ let hover state ~file ~line ~col ~extra ~package =
130130
|> List.filter (fun (l, _) -> not l.Location.loc_ghost)
131131
in
132132
let locations =
133-
let pos = (line, col) in
134-
let pos = Utils.cmtLocFromVscode pos in
133+
let pos = Utils.protocolLineColToCmtLoc ~line ~col in
135134
match References.locForPos ~extra:{extra with locations} pos with
136135
| None -> []
137136
| Some l -> [l]
@@ -200,8 +199,7 @@ let definition state ~file ~line ~col ~extra ~package =
200199
|> List.filter (fun (l, _) -> not l.Location.loc_ghost)
201200
in
202201
let locations =
203-
let pos = (line, col) in
204-
let pos = Utils.cmtLocFromVscode pos in
202+
let pos = Utils.protocolLineColToCmtLoc ~line ~col in
205203
match References.locForPos ~extra:{extra with locations} pos with
206204
| None -> []
207205
| Some l -> [l]

src/Utils.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ let endsWith s suffix =
3939
let l = String.length s in
4040
p <= String.length s && String.sub s (l - p) p = suffix
4141

42-
let cmtLocFromVscode (line, col) = (line + 1, col)
42+
let protocolLineColToCmtLoc ~line ~col = (line + 1, col)
4343

4444
let cmtLocToPosition {Lexing.pos_lnum; pos_cnum; pos_bol} = Protocol.{
4545
line = pos_lnum - 1;

0 commit comments

Comments
 (0)