Skip to content

Clean up hover of namespaced module #845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#### :bug: Bug Fix

- Clean up name of namespaced module when hovering. https://github.com/rescript-lang/rescript-vscode/pull/845
- Fix issue `open` on submodules exposed via `-open` in bsconfig.json/rescript.json, that would cause the content of those `open` modules to not actually appear in autocomplete. https://github.com/rescript-lang/rescript-vscode/pull/842

## 1.22.0
Expand Down
1 change: 1 addition & 0 deletions analysis/src/Hover.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ let showModuleTopLevel ~docstring ~isType ~name (topLevel : Module.item list) =
(* TODO indent *)
|> String.concat "\n"
in
let name = Utils.cutAfterDash name in
let full =
Markdown.codeBlock
("module "
Expand Down
5 changes: 5 additions & 0 deletions analysis/src/Utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,8 @@ let rec lastElements list =
let lowercaseFirstChar s =
if String.length s = 0 then s
else String.mapi (fun i c -> if i = 0 then Char.lowercase_ascii c else c) s

let cutAfterDash s =
match String.index s '-' with
| n -> ( try String.sub s 0 n with Invalid_argument _ -> s)
| exception Not_found -> s