-
Notifications
You must be signed in to change notification settings - Fork 15
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
Alt+I to toggle between .mli/.ml .rei/.re #78
Conversation
src/extension/common/chrome.re
Outdated
@@ -37,6 +42,7 @@ module Tabs = { | |||
/* TODO: could use bs.ginore here? */ | |||
|
|||
external sendMessage : tabId => 'a => ('b => unit) = "chrome.tabs.sendMessage" [@@bs.val]; | |||
external query: Js.t {. active: Js.boolean, currentWindow: Js.boolean} => (array (Js.t {. url: string, id:int}) => unit) => unit = "chrome.tabs.query" [@@bs.val]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first argument here might as well just be Js.t {..}
, right?
src/extension/background.re
Outdated
|
||
Chrome.Commands.addListener ( | ||
fun command => { | ||
Js.log command; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A rogue Js.log
src/extension/background.re
Outdated
Js.log command; | ||
if(command == "toggle_between_interface_and_implementation") { | ||
Chrome.Tabs.query {"active": Js.true_, "currentWindow": Js.true_} {fun activeTab => { | ||
let currentTab = activeTab.(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
activeTab
, a singular, isn't a very good name for an array. The chrome API docs call it result
. You could also just destructure it directly: fun [currentTab] => ...
src/extension/background.re
Outdated
| "rei" => "re" | ||
| ext => ext | ||
}; | ||
let getNewURL url => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getNewURL
is a bit vague for a function at toplevel. How about swapExtension
instead (it doesn't really matter whether it's a url or file path here either)
src/extension/background.re
Outdated
@@ -72,6 +72,35 @@ Chrome.ContextMenus.create { | |||
"onclick": fun _ tab => toggleConversion tab##id | |||
}; | |||
|
|||
let convertExt ext => switch ext { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be shortened to let convertExt = fun | "ml" => "mli" | ...
Also, how about the names mapExtension
or correspondingExtension
instead?
Could you also either run |
@glennsl built with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, this looks good to me now.
Ping @chenglou to merge it in 😄 |
This is awesome! Thanks so much :) |
This is exactly the kind of integration we need to highlight the utility of interface files. Thanks! @rickyvetter we should put this in the readme |
Added a description to the readme. Will also be sure to include in release notes! |
Hi, as promised I added this feature to reason-tools, please let me know what you think of it! Thanks!
CC @chenglou