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

Commit f3dd3e0

Browse files
committed
Fix autocomplete issue where open Foo would be picked up inside line comments.
Fixes #15.
1 parent 51773c6 commit f3dd3e0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## master
22
- Add support for doc strings when hovering on modules.
33
- Add support for printing uncurried function types in hover.
4+
- Fix autocomplete issue where `open Foo` would be picked up inside line comments (see https://github.com/rescript-lang/rescript-editor-support/issues/15).
45

56
## Release 1.0.3 of rescript-vscode
67
This [commit](https://github.com/rescript-lang/rescript-editor-support/commit/214d220d8573f9f0c8d54e623c163e01617bf124) is vendored in [rescript-vscode 1.0.3](https://github.com/rescript-lang/rescript-vscode/releases/tag/1.0.3).

src/rescript-editor-support/PartialParser.re

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ let findCompletable = (text, offset) => {
100100
};
101101
};
102102

103+
// Check if the position is inside a `//` comment
104+
let rec insideLineComment = (text, offset) =>
105+
if (offset <= 0 || text.[offset] == '\n') {
106+
false;
107+
} else if (offset > 0 && text.[offset] == '/' && text.[offset - 1] == '/') {
108+
true;
109+
} else {
110+
insideLineComment(text, offset - 1);
111+
};
112+
103113
let findOpens = (text, offset) => {
104114
let opens = ref([]);
105115
let pathOfModuleOpen = o => {
@@ -128,7 +138,8 @@ let findOpens = (text, offset) => {
128138
&& text.[at - 3] == 'o'
129139
&& text.[at - 2] == 'p'
130140
&& text.[at - 1] == 'e'
131-
&& text.[at] == 'n') {
141+
&& text.[at] == 'n'
142+
&& !insideLineComment(text, at - 4)) {
132143
add(String.sub(text, i + 1, i0 + 1 - (i + 1)));
133144
at - 4;
134145
} else {

0 commit comments

Comments
 (0)