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

Commit

Permalink
Fix autocomplete issue where open Foo would be picked up inside lin…
Browse files Browse the repository at this point in the history
…e comments.

Fixes #15.
  • Loading branch information
cristianoc committed Jan 14, 2021
1 parent 51773c6 commit 1011240
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## master
- Add support for doc strings when hovering on modules.
- Add support for printing uncurried function types in hover.
- Fix autocomplete issue where `open Foo` would be picked up inside line comments (see https://github.com/rescript-lang/rescript-editor-support/issues/15).

## Release 1.0.3 of rescript-vscode
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).
Expand Down
13 changes: 12 additions & 1 deletion src/rescript-editor-support/PartialParser.re
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ let findCompletable = (text, offset) => {
};
};

// Check if the position is inside a `//` comment
let rec insideLineComment = (text, offset) =>
if (offset <= 0 || text.[offset] == '\n') {
false;
} else if (offset > 0 && text.[offset] == '/' && text.[offset - 1] == '/') {
true;
} else {
insideLineComment(text, offset - 1);
};

let findOpens = (text, offset) => {
let opens = ref([]);
let pathOfModuleOpen = o => {
Expand Down Expand Up @@ -128,7 +138,8 @@ let findOpens = (text, offset) => {
&& text.[at - 3] == 'o'
&& text.[at - 2] == 'p'
&& text.[at - 1] == 'e'
&& text.[at] == 'n') {
&& text.[at] == 'n'
&& !insideLineComment(text, at - 4)) {
add(String.sub(text, i + 1, i0 + 1 - (i + 1)));
at - 4;
} else {
Expand Down

0 comments on commit 1011240

Please sign in to comment.